<html>
<head><meta charset="utf-8"><title>Porting benchamark examples · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html">Porting benchamark examples</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="240268813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240268813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240268813">(May 26 2021 at 01:06)</a>:</h4>
<p>I'm making some really silly mistakes but I figure it's best to make the code public so that others can point me in the right direction.<br>
Warning - big noobie mistakes ahead.</p>



<a name="240269070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240269070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240269070">(May 26 2021 at 01:11)</a>:</h4>
<p><a href="https://github.com/rust-lang/stdsimd/pull/122">https://github.com/rust-lang/stdsimd/pull/122</a></p>



<a name="240269118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240269118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240269118">(May 26 2021 at 01:12)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> <span aria-label="muscle" class="emoji emoji-1f4aa" role="img" title="muscle">:muscle:</span></p>



<a name="240269244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240269244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240269244">(May 26 2021 at 01:15)</a>:</h4>
<p>Type names are case sensitive, but also f64x4 should be a valid alias.</p>



<a name="240269280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240269280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240269280">(May 26 2021 at 01:15)</a>:</h4>
<p>Caveats: Rust forte is not these nested for loops but rather chunked iteration that doesn't do bounds checking on every array element access. The benchmarks game explicitly ask to implement <a href="https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/nbody-java-2.html">the Java algorithm</a>, but maybe there is room to tweak some <a href="https://parallel-rust-cpp.github.io/v0.html">high performance</a> tricks out of it.</p>



<a name="240269380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240269380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240269380">(May 26 2021 at 01:17)</a>:</h4>
<p>I tried <code>Simdf64(...)</code> stuff because I kept getting these:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="mi">22</span><span class="w"> </span><span class="o">|</span><span class="w">         </span><span class="n">x</span>: <span class="nc">f64x4</span>::<span class="n">new</span><span class="p">(</span><span class="mf">0.</span><span class="p">,</span><span class="w"> </span><span class="mf">0.</span><span class="p">,</span><span class="w"> </span><span class="mf">0.</span><span class="p">,</span><span class="w"> </span><span class="mf">0.</span><span class="p">),</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w">                   </span><span class="o">^^^</span><span class="w"> </span><span class="n">function</span><span class="w"> </span><span class="n">or</span><span class="w"> </span><span class="n">associated</span><span class="w"> </span><span class="n">item</span><span class="w"> </span><span class="n">not</span><span class="w"> </span><span class="n">found</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="err">`</span><span class="n">SimdF64</span><span class="o">&lt;</span><span class="mi">4_</span><span class="k">usize</span><span class="o">&gt;</span><span class="err">`</span><span class="w"></span>
</code></pre></div>



<a name="240269480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240269480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240269480">(May 26 2021 at 01:18)</a>:</h4>
<p>Also, I looked around this chat for some more Playground examples but other than working out the test macros in my head I don't know other <code>stdsimd</code> examples lying around <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="240272178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240272178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240272178">(May 26 2021 at 02:10)</a>:</h4>
<p>Ok turns out using <code>f64x4::new(...)</code> isn't kosher, so <code>f64x4::from_array([...])</code> was the way to go.</p>



<a name="240272203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240272203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240272203">(May 26 2021 at 02:11)</a>:</h4>
<p>Ah, we... probably want to have some sort of notes in the docs on that maybe?</p>



<a name="240272218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240272218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240272218">(May 26 2021 at 02:11)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span> beats me.</p>



<a name="240272226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240272226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240272226">(May 26 2021 at 02:11)</a>:</h4>
<p>How can I make Rust not complain about this though?</p>



<a name="240272270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240272270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240272270">(May 26 2021 at 02:12)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#[derive(Debug)]</span><span class="w"></span>
<span class="cp">#[repr(simd)]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Body</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">x</span>: <span class="nc">f64x4</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">v</span>: <span class="nc">f64x4</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">mass</span>: <span class="kt">f64</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="240272290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240272290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240272290">(May 26 2021 at 02:12)</a>:</h4>
<p>It says: <code>E0076 sIMD Vector should be homogenous. SIMD elements must have the same type</code>.</p>



<a name="240272293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240272293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240272293">(May 26 2021 at 02:12)</a>:</h4>
<p>you can't use repr(simd), for one</p>



<a name="240272298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240272298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240272298">(May 26 2021 at 02:12)</a>:</h4>
<p>Oh, that fixes it.</p>



<a name="240272309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240272309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240272309">(May 26 2021 at 02:13)</a>:</h4>
<p>you also probably want to derive Clone and Copy</p>



<a name="240272666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240272666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240272666">(May 26 2021 at 02:20)</a>:</h4>
<p><span class="user-mention silent" data-user-id="246783">Miguel Raz Guzmán Macedo</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/240269280">said</a>:</p>
<blockquote>
<p>Caveats: Rust forte is not these nested for loops but rather chunked iteration that doesn't do bounds checking on every array element access. The benchmarks game explicitly ask to implement <a href="https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/nbody-java-2.html">the Java algorithm</a>, but maybe there is room to tweak some <a href="https://parallel-rust-cpp.github.io/v0.html">high performance</a> tricks out of it.</p>
</blockquote>
<p>I don't particularly care about the benchmarks game website, but insofar as it does matter:<br>
Iterator is <strong>exactly</strong> a for loop, so the difference would be largely syntactic.<br>
Because a for loop <strong>creates</strong> an iterator.</p>



<a name="240272971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240272971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240272971">(May 26 2021 at 02:26)</a>:</h4>
<p>Alright, replaced <code>sum()</code> with <code>horizontal_sum()</code> where relevant.</p>



<a name="240272999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240272999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240272999">(May 26 2021 at 02:26)</a>:</h4>
<p>Anyone have a clue what <code>write_to_slice_unaligned(...)</code> could be replaced with?</p>



<a name="240273035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273035">(May 26 2021 at 02:27)</a>:</h4>
<p>I think we may still need a function for that</p>



<a name="240273045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273045">(May 26 2021 at 02:27)</a>:</h4>
<p>You can do it with a pointer and unsafe</p>



<a name="240273049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273049">(May 26 2021 at 02:27)</a>:</h4>
<p>for <em>unaligned</em> you need the special function, even for pointers and unsafe</p>



<a name="240273104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273104">(May 26 2021 at 02:28)</a>:</h4>
<p>...is this a bad time to confess I've yet to work with pointers? <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="240273113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273113">(May 26 2021 at 02:29)</a>:</h4>
<p>Yeah, you would cast the scalar pointer to a vector pointer and use <code>write_unaligned</code></p>



<a name="240273118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273118">(May 26 2021 at 02:29)</a>:</h4>
<p>Haha, no, in rust it's usually unnecessary</p>



<a name="240273121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273121">(May 26 2021 at 02:29)</a>:</h4>
<p>Garbage Collectors! They save you from thinking about pointers! <span aria-label="muscle" class="emoji emoji-1f4aa" role="img" title="muscle">:muscle:</span> !</p>



<a name="240273127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273127">(May 26 2021 at 02:29)</a>:</h4>
<p>you usually don't need pointers in rust</p>



<a name="240273130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273130">(May 26 2021 at 02:29)</a>:</h4>
<p>The difference is that <code>for</code> loop has a subtlety in that it supports certain more interesting kinds of control flow, which denies certain optimizations that can be used in the absence of them. Creating an iterator chain and doing equivalent calls limits the control flow options, and thus allows more optimizations to be used.</p>



<a name="240273146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273146">(May 26 2021 at 02:29)</a>:</h4>
<p>but i'm unclear why you're "replacing" write_to_slice_unaligned with something, because that sounds like it does precisely what you want</p>



<a name="240273193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273193">(May 26 2021 at 02:30)</a>:</h4>
<p>We don't have that function yet</p>



<a name="240273200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273200">(May 26 2021 at 02:30)</a>:</h4>
<p>oh that would do it</p>



<a name="240273222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273222">(May 26 2021 at 02:30)</a>:</h4>
<p>There's no such creative control flow in the benchmarks game algorithm, that I can see, and therefore no real semantic difference.</p>



<a name="240273245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273245">(May 26 2021 at 02:31)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> don't these kinda for loops do inherent inbounds checking?</p>



<a name="240273250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273250">(May 26 2021 at 02:31)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">f64x4</span>::<span class="n">splat</span><span class="p">(</span><span class="mf">0.</span><span class="p">);</span><span class="w"> </span><span class="n">N</span><span class="p">];</span><span class="w"></span>
<span class="w">    </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"></span>
<span class="w">        </span><span class="k">for</span><span class="w"> </span><span class="n">j</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="mi">0</span><span class="o">..</span><span class="n">N_BODIES</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="k">for</span><span class="w"> </span><span class="n">k</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">j</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="o">..</span><span class="n">N_BODIES</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="n">r</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">bodies</span><span class="p">[</span><span class="n">j</span><span class="p">].</span><span class="n">x</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">bodies</span><span class="p">[</span><span class="n">k</span><span class="p">].</span><span class="n">x</span><span class="p">;</span><span class="w"></span>
<span class="w">                </span><span class="n">i</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"></span>
<span class="w">            </span><span class="p">}</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="240273298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273298">(May 26 2021 at 02:32)</a>:</h4>
<p>That what I remember reading in the <code>High Performance </code> Rust book.</p>



<a name="240273307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273307">(May 26 2021 at 02:32)</a>:</h4>
<p>yeah those loops like that are (not)secretly worse in rust than using an iterator "properly"</p>



<a name="240273320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273320">(May 26 2021 at 02:33)</a>:</h4>
<p>Yes, you are correct.<br>
However, you will notice that the value of <code>i</code> is totally deterministic.</p>



<a name="240273333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273333">(May 26 2021 at 02:33)</a>:</h4>
<p>Yeah, that's what I surmised - I know idiomatic iterator Rust is to known work around.</p>



<a name="240273400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273400">(May 26 2021 at 02:34)</a>:</h4>
<p>I'm also guessing that those bounds checking are going to cobble SIMDification attempts - they would in Julia.</p>



<a name="240273428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273428">(May 26 2021 at 02:35)</a>:</h4>
<p>They would, yes.</p>



<a name="240273477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273477">(May 26 2021 at 02:36)</a>:</h4>
<p>mostly (unless the size is static and llvm eliminates the checks), but it will also likely not be auto-simd because of the i/j/k interactions doin a bamboozle to llvm</p>



<a name="240273512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273512">(May 26 2021 at 02:36)</a>:</h4>
<p>Indeed, LLVM can only barely see through 2 layers of indirection here.</p>



<a name="240273536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273536">(May 26 2021 at 02:37)</a>:</h4>
<p><a href="https://github.com/rust-lang/packed_simd/blob/master/src/api/slice/write_to_slice.rs">https://github.com/rust-lang/packed_simd/blob/master/src/api/slice/write_to_slice.rs</a> Looks like this is the implementation for <code>write_to_slice_unaligned</code>.</p>



<a name="240273617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273617">(May 26 2021 at 02:39)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">                </span><span class="cp">#[allow(clippy::cast_ptr_alignment)]</span><span class="w"></span>
<span class="w">                </span><span class="cp">#[allow(clippy::cast_ptr_alignment)]</span><span class="w"></span>
<span class="w">                </span><span class="cp">#[allow(clippy::cast_ptr_alignment)]</span><span class="w"></span>
<span class="w">                </span><span class="cp">#[allow(clippy::cast_ptr_alignment)]</span><span class="w"></span>
<span class="w">                </span><span class="o">*</span><span class="p">(</span><span class="n">target_ptr</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">mut</span><span class="w"> </span><span class="bp">Self</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">;</span><span class="w"></span>
</code></pre></div>



<a name="240273875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273875">(May 26 2021 at 02:44)</a>:</h4>
<p>Okay so, <code>write_to_slice_unaligned</code> is actually not very magical and it doesn't even do what i thought it did based on the name.</p>
<p>so what you want is something like: <code>dest[sub_slice_selection_here].copy_from_slice(src_simd.to_array())</code></p>



<a name="240273886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240273886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240273886">(May 26 2021 at 02:45)</a>:</h4>
<p>note that copy_from_slice requires that the dest and src have the same length, so you'll have to pick the correct amount of elements from dest based on the lane count of size</p>



<a name="240274104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240274104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240274104">(May 26 2021 at 02:49)</a>:</h4>
<p>I am not convinced that's what you want?  I'd be curious to see the codegen</p>



<a name="240277849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240277849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240277849">(May 26 2021 at 04:13)</a>:</h4>
<p>wait, do we have an <code>simd_finvsqrt</code> intrinsic function? Those are definitely useful.<br>
My ripgreppin' says no.</p>



<a name="240278354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240278354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240278354">(May 26 2021 at 04:25)</a>:</h4>
<p>It seems the inverse sqrt SIMD intrinsic  (<code>_mm_rsqrt_ps</code>) is available from the <a href="https://llvm.org/doxygen/X86IntrinsicsInfo_8h_source.html">langref</a> and this neat <a href="https://youtu.be/4Gs_CA_vm3o?t=2424">tutorial video</a></p>
<div class="youtube-video message_inline_image"><a data-id="4Gs_CA_vm3o" href="https://youtu.be/4Gs_CA_vm3o?t=2424"><img src="https://uploads.zulipusercontent.net/30b3ad7d7d3066bfe28ee5400da3091fa653c91d/68747470733a2f2f692e7974696d672e636f6d2f76692f3447735f43415f766d336f2f64656661756c742e6a7067"></a></div>



<a name="240279697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240279697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240279697">(May 26 2021 at 04:52)</a>:</h4>
<p>I'm working on adding an rsqrt function to vector-math, it will likely share implementations with the fallback sqrt function. Btw, I think rsqrt is a better name than invsqrt, since invsqrt could mean either inverse sqrt as in reciprocal or as in inverse function (which would end up being <code>x*x</code>)</p>



<a name="240280348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240280348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240280348">(May 26 2021 at 05:08)</a>:</h4>
<p>Ugh <span class="user-mention" data-user-id="229517">@Jacob Lifshay</span> , I just missed your comment <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span> <a href="https://github.com/rust-lang/stdsimd/pull/123">https://github.com/rust-lang/stdsimd/pull/123</a></p>



<a name="240281830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240281830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240281830">(May 26 2021 at 05:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/240274104">said</a>:</p>
<blockquote>
<p>I am not convinced that's what you want?  I'd be curious to see the codegen</p>
</blockquote>
<p>maybe it's not what you want, but that's the equivalent of what the <code>write_to_slice_unaligned</code> code does</p>



<a name="240333184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240333184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240333184">(May 26 2021 at 14:29)</a>:</h4>
<p>I opened a PR with the function doing what I'd expect it to do <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="240335033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240335033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240335033">(May 26 2021 at 14:40)</a>:</h4>
<p>caleb you just did what I was already saying XD</p>



<a name="240335122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240335122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240335122">(May 26 2021 at 14:41)</a>:</h4>
<p>Lol maybe I was confused</p>



<a name="240335142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240335142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240335142">(May 26 2021 at 14:41)</a>:</h4>
<p>I was worried about using from_array</p>



<a name="240353969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240353969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240353969">(May 26 2021 at 16:40)</a>:</h4>
<p>worried how?</p>



<a name="240354059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240354059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240354059">(May 26 2021 at 16:41)</a>:</h4>
<p>In the context of reading and writing from a slice it would be an extra conversion that the compiler might get confused by?  It might be fine</p>



<a name="240354082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240354082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240354082">(May 26 2021 at 16:41)</a>:</h4>
<p>But I'd rather just read the vector type directly</p>



<a name="240354102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240354102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240354102">(May 26 2021 at 16:41)</a>:</h4>
<p>With an unaligned read</p>



<a name="240354576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240354576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240354576">(May 26 2021 at 16:45)</a>:</h4>
<p>if we add a function every single time that LLVM might be confused we might as well write in assembly.</p>



<a name="240354799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240354799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240354799">(May 26 2021 at 16:46)</a>:</h4>
<p>Hmm maybe I'm missing something, I think reading from slices is something that is common and we should have in our API? And it makes more sense to do it as a single pointer read IMO</p>



<a name="240354997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240354997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240354997">(May 26 2021 at 16:48)</a>:</h4>
<p>I think people should just have slices of f32x4 (or whatever type).</p>



<a name="240355061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240355061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240355061">(May 26 2021 at 16:48)</a>:</h4>
<p>It's more that reading from and writing to slices is not completely obvious so we can provide the implementation</p>



<a name="240355138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240355138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240355138">(May 26 2021 at 16:49)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> that would require aligned loads and stores</p>



<a name="240355168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240355168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240355168">(May 26 2021 at 16:49)</a>:</h4>
<p>correct</p>



<a name="240355276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240355276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240355276">(May 26 2021 at 16:50)</a>:</h4>
<p>rather, it would give them aligned loads and stores is a better way to say it</p>



<a name="240355413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240355413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240355413">(May 26 2021 at 16:51)</a>:</h4>
<p>Yes, and you can use <code>align_to</code> for that</p>



<a name="240355469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240355469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240355469">(May 26 2021 at 16:51)</a>:</h4>
<p>But in many situations you can't use aligned loads and stores</p>



<a name="240355768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240355768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240355768">(May 26 2021 at 16:53)</a>:</h4>
<p>Arm doesn't make a distinction and most Intel CPUs don't have a significant penalty for unaligned access so most algorithms I've worked with use unaligned accesses exclusively</p>



<a name="240358264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240358264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240358264">(May 26 2021 at 17:10)</a>:</h4>
<p>It depends on the unaligned access. The performance penalty varies from +0% to +50%.</p>



<a name="240358325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240358325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240358325">(May 26 2021 at 17:11)</a>:</h4>
<p>Significantly lower overhead than a memcpy to realign inherently unaligned data</p>



<a name="240358369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240358369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240358369">(May 26 2021 at 17:11)</a>:</h4>
<p>We shouldn't preclude unaligned accesses</p>



<a name="240358423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240358423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240358423">(May 26 2021 at 17:12)</a>:</h4>
<p>Or even discourage them</p>



<a name="240359269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240359269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240359269">(May 26 2021 at 17:18)</a>:</h4>
<p>I am pretty sure LLVM already emits vectorized memcpy, actually.</p>



<a name="240359397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240359397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240359397">(May 26 2021 at 17:19)</a>:</h4>
<p>It does but that's not what I mean.</p>



<a name="240359471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240359471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240359471">(May 26 2021 at 17:19)</a>:</h4>
<p>If you have 1000 f32s, inherently unaligned, I'd rather just do unaligned access than allocate new aligned memory and copy it</p>



<a name="240359509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240359509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240359509">(May 26 2021 at 17:19)</a>:</h4>
<p>There's nothing wrong with doing unaligned accesses</p>



<a name="240359592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240359592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240359592">(May 26 2021 at 17:20)</a>:</h4>
<p>????????</p>



<a name="240359618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240359618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240359618">(May 26 2021 at 17:20)</a>:</h4>
<p>If you look at vector libraries like IPP or MKL they don't even bother using aligned access</p>



<a name="240359624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240359624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240359624">(May 26 2021 at 17:20)</a>:</h4>
<p>I wasn't aware I was arguing that.</p>



<a name="240359684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240359684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240359684">(May 26 2021 at 17:21)</a>:</h4>
<p>I thought you were arguing against the functions I added in my PR</p>



<a name="240359740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240359740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240359740">(May 26 2021 at 17:21)</a>:</h4>
<p>I think we're on different pages haha</p>



<a name="240359826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240359826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240359826">(May 26 2021 at 17:22)</a>:</h4>
<p>If I want to do that then there's a million issues I could have with them that don't have to do with alignment, and I just woke up so I haven't even decided how many nits I want to pick before I go to sleep. :^)</p>



<a name="240359985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240359985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240359985">(May 26 2021 at 17:23)</a>:</h4>
<p>so it's more that I'm here and going "hey guys what's going on in this thread"</p>



<a name="240360042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240360042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240360042">(May 26 2021 at 17:23)</a>:</h4>
<p>Good morning <span class="user-mention" data-user-id="281757">@Jubilee</span> <span aria-label="wave" class="emoji emoji-1f44b" role="img" title="wave">:wave:</span></p>



<a name="240974836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240974836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240974836">(Jun 01 2021 at 17:19)</a>:</h4>
<p>So the conclusion to <code>dmags.write_to_slice_unaligned(&amp;mut mag[i...]);</code> is that I should use which method instead? <span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> I think you merged a PR with the equivalent function right?</p>



<a name="240974901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240974901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240974901">(Jun 01 2021 at 17:19)</a>:</h4>
<p>No PR has been merged yet</p>



<a name="240975337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240975337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240975337">(Jun 01 2021 at 17:23)</a>:</h4>
<p>alright I'll refactor the <code>run_k</code> function instead for now.</p>



<a name="240976802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240976802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240976802">(Jun 01 2021 at 17:33)</a>:</h4>
<p>Alright, I've refactored it <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="240978255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240978255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240978255">(Jun 01 2021 at 17:44)</a>:</h4>
<p>OK, I've re-read the code. I've tried reading the <code>packed_simd</code> implementation of <code>write_to_slice_unaligned</code> but the <code>impl_f!</code> rabbit hole got waaay too gnarly.<br>
<span class="user-mention" data-user-id="281757">@Jubilee</span> any ideas on how to proceed?</p>



<a name="240979688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240979688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240979688">(Jun 01 2021 at 17:55)</a>:</h4>
<p>phew, finally found it <a href="https://github.com/rust-lang/packed_simd/blob/f60e900f4ceb71303baa37ff8b41ee7d490c01bf/src/api/slice/write_to_slice.rs">https://github.com/rust-lang/packed_simd/blob/f60e900f4ceb71303baa37ff8b41ee7d490c01bf/src/api/slice/write_to_slice.rs</a></p>



<a name="240981275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240981275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240981275">(Jun 01 2021 at 18:06)</a>:</h4>
<p>Trying to monkey patch this:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">            </span><span class="cp">#[inline]</span><span class="w"></span>
<span class="w">            </span><span class="k">pub</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="k">fn</span> <span class="nf">write_to_slice_aligned_unchecked</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">slice</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="p">[</span><span class="cp">$elem_ty</span><span class="p">])</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="fm">debug_assert!</span><span class="p">(</span><span class="n">slice</span><span class="p">.</span><span class="n">len</span><span class="p">()</span><span class="w"> </span><span class="o">&gt;=</span><span class="w"> </span><span class="cp">$elem_count</span><span class="p">);</span><span class="w"></span>
<span class="w">                </span><span class="kd">let</span><span class="w"> </span><span class="n">target_ptr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">slice</span><span class="p">.</span><span class="n">get_unchecked_mut</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">mut</span><span class="w"> </span><span class="cp">$elem_ty</span><span class="p">;</span><span class="w"></span>
<span class="w">                </span><span class="fm">debug_assert_eq!</span><span class="p">(</span><span class="n">target_ptr</span><span class="p">.</span><span class="n">align_offset</span><span class="p">(</span><span class="k">crate</span>::<span class="n">mem</span>::<span class="n">align_of</span>::<span class="o">&lt;</span><span class="bp">Self</span><span class="o">&gt;</span><span class="p">()),</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span><span class="w"></span>

<span class="w">                </span><span class="cp">#[allow(clippy::cast_ptr_alignment)]</span><span class="w"></span>
<span class="w">                </span><span class="cp">#[allow(clippy::cast_ptr_alignment)]</span><span class="w"></span>
<span class="w">                </span><span class="cp">#[allow(clippy::cast_ptr_alignment)]</span><span class="w"></span>
<span class="w">                </span><span class="cp">#[allow(clippy::cast_ptr_alignment)]</span><span class="w"></span>
<span class="w">                </span><span class="o">*</span><span class="p">(</span><span class="n">target_ptr</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">mut</span><span class="w"> </span><span class="bp">Self</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">;</span><span class="w"></span>
<span class="w">            </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="240981293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240981293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240981293">(Jun 01 2021 at 18:07)</a>:</h4>
<p>with something like this:</p>



<a name="240981334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240981334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240981334">(Jun 01 2021 at 18:07)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#[inline]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="k">fn</span> <span class="nf">write_to_slice_unaligned</span><span class="p">(</span><span class="n">slice</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="n">SimdF64</span>::<span class="o">&lt;</span><span class="n">LANES</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">target_ptr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">slice</span><span class="p">.</span><span class="n">get_unchecked_mut</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">mut</span><span class="w"> </span><span class="n">f64x2</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="o">*</span><span class="p">(</span><span class="n">target_ptr</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">mut</span><span class="w"> </span><span class="n">f64x2</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">SimdF64</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="240988638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240988638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240988638">(Jun 01 2021 at 19:02)</a>:</h4>
<p>uh, well that doesn't really write it to a slice in an unaligned way</p>



<a name="240989087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/240989087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#240989087">(Jun 01 2021 at 19:07)</a>:</h4>
<p>dmags is just f64x2 and you're writing it to a slice with 2 elements.<br>
for now, just scalarize it, as that is the safest way to handle it.</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">mag</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">dmags</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span><span class="w"></span>
<span class="n">mag</span><span class="p">[</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">dmags</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span><span class="w"></span>
</code></pre></div>



<a name="241069399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241069399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241069399">(Jun 01 2021 at 20:17)</a>:</h4>
<p>Gotcha.</p>



<a name="241069994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241069994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241069994">(Jun 01 2021 at 20:22)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">   </span><span class="o">-</span>-&gt; <span class="nc">crates</span><span class="o">/</span><span class="n">core_simd</span><span class="o">/</span><span class="n">examples</span><span class="o">/</span><span class="n">nbody</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">169</span>:<span class="mi">26</span><span class="w"></span>
<span class="w">    </span><span class="o">|</span><span class="w"></span>
<span class="mi">169</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">OUTPUT</span>: <span class="nb">Vec</span><span class="o">&lt;</span><span class="kt">f64</span><span class="o">&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="fm">vec!</span><span class="p">[</span><span class="o">-</span><span class="mf">0.169075164</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mf">0.169087605</span><span class="p">];</span><span class="w"></span>
<span class="w">    </span><span class="o">|</span><span class="w">                          </span><span class="o">^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</span><span class="w"> </span><span class="n">allocation</span><span class="w"> </span><span class="n">not</span><span class="w"> </span><span class="n">allowed</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">constants</span><span class="w"></span>
<span class="w">    </span><span class="o">|</span><span class="w"></span>
<span class="w">    </span><span class="o">=</span><span class="w"> </span><span class="n">note</span>: <span class="nc">this</span><span class="w"> </span><span class="n">error</span><span class="w"> </span><span class="n">originates</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="kr">macro</span><span class="w"> </span><span class="p">(</span><span class="k">in</span><span class="w"> </span><span class="n">Nightly</span><span class="w"> </span><span class="n">builds</span><span class="p">,</span><span class="w"> </span><span class="n">run</span><span class="w"> </span><span class="n">with</span><span class="w"> </span><span class="o">-</span><span class="n">Z</span><span class="w"> </span><span class="kr">macro</span><span class="o">-</span><span class="n">backtrace</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">more</span><span class="w"> </span><span class="n">info</span><span class="p">)</span><span class="w"></span>
</code></pre></div>
<p>How do I make a <code>const</code> vector again?</p>



<a name="241070374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241070374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241070374">(Jun 01 2021 at 20:25)</a>:</h4>
<p><code>const OUTPUT: [f64; 2] = [1.0, 2.0];</code> seems to have done it.</p>



<a name="241071188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241071188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241071188">(Jun 01 2021 at 20:31)</a>:</h4>
<p>yeah.</p>



<a name="241083082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241083082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241083082">(Jun 01 2021 at 22:22)</a>:</h4>
<p>and you can use the const union hack if you need an actual simd value as a const.</p>



<a name="241083131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241083131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241083131">(Jun 01 2021 at 22:22)</a>:</h4>
<p>(but the const union hack doesn't work in const fn because... don't remember)</p>



<a name="241084560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241084560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241084560">(Jun 01 2021 at 22:39)</a>:</h4>
<p>Something something dependent types</p>



<a name="241084562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241084562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241084562">(Jun 01 2021 at 22:39)</a>:</h4>
<p>Probably.</p>



<a name="241089681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241089681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241089681">(Jun 01 2021 at 23:45)</a>:</h4>
<p>I don't know those wizardries yet <span class="user-mention" data-user-id="224471">@Lokathor</span> <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="241090130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241090130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241090130">(Jun 01 2021 at 23:51)</a>:</h4>
<p>you <em>probably</em> don't need it.</p>



<a name="241090241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241090241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241090241">(Jun 01 2021 at 23:53)</a>:</h4>
<p>yeah it's just a dumb thing some libs do. in a benchmark example it's not necessary</p>



<a name="241090361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241090361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241090361">(Jun 01 2021 at 23:55)</a>:</h4>
<p>Oh sweet - I just need the floating point <code>assert_eq!</code> where can I get that for the example?</p>



<a name="241090457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241090457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241090457">(Jun 01 2021 at 23:57)</a>:</h4>
<p>"floating point assert_eq"?</p>



<a name="241091357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241091357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241091357">(Jun 02 2021 at 00:11)</a>:</h4>
<p>assert_eq works on f32 and f64 arrays already</p>



<a name="241091369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241091369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241091369">(Jun 02 2021 at 00:11)</a>:</h4>
<p>however, you <em>might</em> want an assert_approximately macro instead</p>



<a name="241091688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241091688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241091688">(Jun 02 2021 at 00:17)</a>:</h4>
<p>or just a function:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#[track_caller]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">assert_within</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">(</span><span class="n">max_diff</span>: <span class="kt">f32</span><span class="p">,</span><span class="w"> </span><span class="n">a</span>: <span class="p">[</span><span class="kt">f32</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">],</span><span class="w"> </span><span class="n">b</span>: <span class="p">[</span><span class="kt">f32</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">])</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="n">ax</span><span class="w"> </span><span class="n">bx</span><span class="p">)</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">a</span><span class="p">.</span><span class="n">iter</span><span class="p">().</span><span class="n">copied</span><span class="p">().</span><span class="n">zip</span><span class="p">(</span><span class="n">b</span><span class="p">.</span><span class="n">iter</span><span class="p">().</span><span class="n">copied</span><span class="p">())</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">ax</span><span class="o">-</span><span class="n">bx</span><span class="p">).</span><span class="n">abs</span><span class="p">()</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="n">max_diff</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="fm">panic!</span><span class="p">(</span><span class="s">"some values exceeded the maximum allowed difference of {}:</span><span class="se">\n</span><span class="s">A: {:?}</span><span class="se">\n</span><span class="s">B:{:?}"</span><span class="p">,</span><span class="w"> </span><span class="n">max_diff</span><span class="p">,</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="w">  </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>anything like that, which checks that each lane is close enough to a given value.</p>
<p>Of course this doesn't handle nan so, ya know.</p>



<a name="241091784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241091784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241091784">(Jun 02 2021 at 00:18)</a>:</h4>
<p>I get this</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="o">----</span><span class="w"> </span><span class="n">tests</span>::<span class="n">test</span><span class="w"> </span><span class="n">stdout</span><span class="w"> </span><span class="o">----</span><span class="w"></span>
<span class="n">thread</span><span class="w"> </span><span class="o">'</span><span class="na">tests</span>::<span class="n">test</span><span class="o">'</span><span class="w"> </span><span class="n">panicked</span><span class="w"> </span><span class="n">at</span><span class="w"> </span><span class="o">'</span><span class="na">assertion</span><span class="w"> </span><span class="n">failed</span>: <span class="err">`</span><span class="p">(</span><span class="n">left</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">right</span><span class="p">)</span><span class="err">`</span><span class="w"></span>
<span class="w">  </span><span class="n">left</span>: <span class="err">`</span><span class="o">-</span><span class="mf">0.16907516382852447</span><span class="err">`</span><span class="p">,</span><span class="w"></span>
<span class="w"> </span><span class="n">right</span>: <span class="err">`</span><span class="o">-</span><span class="mf">0.169075164</span><span class="err">`</span><span class="o">'</span><span class="p">,</span><span class="w"> </span><span class="n">crates</span><span class="o">/</span><span class="n">core_simd</span><span class="o">/</span><span class="n">examples</span><span class="o">/</span><span class="n">nbody</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">180</span>:<span class="mi">13</span><span class="w"></span>
<span class="n">note</span>: <span class="nc">run</span><span class="w"> </span><span class="n">with</span><span class="w"> </span><span class="err">`</span><span class="n">RUST_BACKTRACE</span><span class="o">=</span><span class="mi">1</span><span class="err">`</span><span class="w"> </span><span class="n">environment</span><span class="w"> </span><span class="n">variable</span><span class="w"> </span><span class="n">to</span><span class="w"> </span><span class="n">display</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="n">backtrace</span><span class="w"></span>
</code></pre></div>



<a name="241091842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241091842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241091842">(Jun 02 2021 at 00:20)</a>:</h4>
<p>I like Lokathor's answer re: <code>assert_within</code>.</p>



<a name="241091900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241091900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241091900">(Jun 02 2021 at 00:20)</a>:</h4>
<p>yes the standard assert will only use the normal <code>==</code> operator, which is generally too exacting with floats, which is why one generally needs to use an approximation function instead.</p>



<a name="241091937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241091937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241091937">(Jun 02 2021 at 00:21)</a>:</h4>
<p>in part of my safe_arch test suite, for example, i have these helpers:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#[allow(dead_code)]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">approx_eq_f32</span><span class="p">(</span><span class="n">a</span>: <span class="kt">f32</span><span class="p">,</span><span class="w"> </span><span class="n">b</span>: <span class="kt">f32</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">bool</span> <span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="p">(</span><span class="n">a</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">b</span><span class="p">).</span><span class="n">abs</span><span class="p">()</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="mf">0.00000001</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[allow(dead_code)]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">approx_eq_f64</span><span class="p">(</span><span class="n">a</span>: <span class="kt">f64</span><span class="p">,</span><span class="w"> </span><span class="n">b</span>: <span class="kt">f64</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">bool</span> <span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="p">(</span><span class="n">a</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">b</span><span class="p">).</span><span class="n">abs</span><span class="p">()</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="mf">0.00000000001</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="241092768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241092768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241092768">(Jun 02 2021 at 00:32)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> alright, tests are passing locally with a small fudge on the floating point equality</p>



<a name="241092782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241092782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241092782">(Jun 02 2021 at 00:32)</a>:</h4>
<p>Can I get any eyes on <a href="https://github.com/rust-lang/stdsimd/pull/122">https://github.com/rust-lang/stdsimd/pull/122</a> please team?</p>



<a name="241093102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241093102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241093102">(Jun 02 2021 at 00:37)</a>:</h4>
<p>well CI is very unhappy at the latest push</p>



<a name="241093129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241093129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241093129">(Jun 02 2021 at 00:37)</a>:</h4>
<p>Wow, rude.</p>



<a name="241093193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241093193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241093193">(Jun 02 2021 at 00:38)</a>:</h4>
<p>So uh, how do people inspect the LLVM IR and Assembly that's outputted by each function?<br>
I got spoiled that in Julia I can do <code>@code_llvm foo(x)</code> and that will just work <span aria-label="tm" class="emoji emoji-2122" role="img" title="tm">:tm:</span></p>



<a name="241093800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241093800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241093800">(Jun 02 2021 at 00:47)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> I think it's because I didn't have a <code>fn main()</code></p>



<a name="241093841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241093841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241093841">(Jun 02 2021 at 00:48)</a>:</h4>
<p>cargo will uhm... do it... somehow?</p>



<a name="241093890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241093890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241093890">(Jun 02 2021 at 00:48)</a>:</h4>
<p>i haven't had to do it outside of godbolt in ages i forget how to make cargo do it</p>



<a name="241093934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241093934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241093934">(Jun 02 2021 at 00:49)</a>:</h4>
<p>You can do <code>-Cemit=llvm-ir</code> I think</p>



<a name="241093951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241093951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241093951">(Jun 02 2021 at 00:49)</a>:</h4>
<p>yeah SO says <code>cargo rustc -- --emit=llvm-ir</code> will do it.</p>



<a name="241094079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241094079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241094079">(Jun 02 2021 at 00:51)</a>:</h4>
<p>hmmm - It says the build finished but nothing printed to my terminal - does it dump the llvm-ir into <code>target/</code> or something?</p>



<a name="241094094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241094094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241094094">(Jun 02 2021 at 00:51)</a>:</h4>
<p>It will save it to <code>target/{mode}/deps/{crate}.ll</code></p>



<a name="241094107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241094107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241094107">(Jun 02 2021 at 00:51)</a>:</h4>
<p>gotcha</p>



<a name="241094130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241094130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241094130">(Jun 02 2021 at 00:51)</a>:</h4>
<p>Mode meaning debug or release (or a cross compile target)</p>



<a name="241094189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241094189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241094189">(Jun 02 2021 at 00:52)</a>:</h4>
<p>It will actually emit IR for all of your dependencies as well which is occasionally useful</p>



<a name="241094245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241094245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241094245">(Jun 02 2021 at 00:53)</a>:</h4>
<p>oof, there's quite a few files here</p>



<a name="241094341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241094341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241094341">(Jun 02 2021 at 00:54)</a>:</h4>
<p>hmmmm didn't find it</p>



<a name="241094373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241094373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241094373">(Jun 02 2021 at 00:55)</a>:</h4>
<p>yeah the interface for that emit thing is... poor</p>



<a name="241094477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241094477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241094477">(Jun 02 2021 at 00:56)</a>:</h4>
<p>Y'all are missing out!</p>
<div class="codehilite" data-code-language="Julia"><pre><span></span><code><span class="n">julia</span><span class="o">&gt;</span> <span class="n">foo</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">=</span> <span class="n">x</span><span class="o">^</span><span class="mi">2</span>
<span class="n">foo</span> <span class="p">(</span><span class="n">generic</span> <span class="k">function</span> <span class="n">with</span> <span class="mi">1</span> <span class="n">method</span><span class="p">)</span>

<span class="n">julia</span><span class="o">&gt;</span> <span class="nd">@code_llvm</span> <span class="n">foo</span><span class="p">(</span><span class="mf">3.0</span><span class="p">)</span>
<span class="p">;</span>  <span class="err">@</span> <span class="n">REPL</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">:</span><span class="mi">1</span> <span class="n">within</span> <span class="sb">`foo'</span>
<span class="sb">define double @julia_foo_718(double %0) {</span>
<span class="sb">top:</span>
<span class="sb">; ┌ @ intfuncs.jl:312 within `</span><span class="sa">literal_pow</span><span class="o">'</span>
<span class="p">;</span> <span class="n">│┌</span> <span class="err">@</span> <span class="n">float</span><span class="o">.</span><span class="n">jl</span><span class="o">:</span><span class="mi">332</span> <span class="n">within</span> <span class="sb">`*'</span>
<span class="sb">    %1 = fmul double %0, %0</span>
<span class="sb">; └└</span>
<span class="sb">  ret double %1</span>
<span class="sb">}</span>

<span class="sb">julia&gt; @code_llvm foo(3)</span>
<span class="sb">;  @ REPL[1]:1 within `</span><span class="sa">foo</span><span class="o">'</span>
<span class="n">define</span> <span class="n">i64</span> <span class="nd">@julia_foo_735</span><span class="p">(</span><span class="n">i64</span> <span class="n">signext</span> <span class="o">%</span><span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
<span class="kt">top</span><span class="o">:</span>
<span class="p">;</span> <span class="kt">┌</span> <span class="err">@</span> <span class="kt">intfuncs</span><span class="o">.</span><span class="kt">jl</span><span class="o">:</span><span class="mi">312</span> <span class="kt">within</span> <span class="sb">`literal_pow'</span>
<span class="sb">; │┌ @ int.jl:88 within `</span><span class="o">*</span><span class="err">'</span>
    <span class="o">%</span><span class="mi">1</span> <span class="o">=</span> <span class="kt">mul</span> <span class="kt">i64</span> <span class="o">%</span><span class="mi">0</span><span class="p">,</span> <span class="o">%</span><span class="mi">0</span>
<span class="p">;</span> <span class="kt">└└</span>
  <span class="kt">ret</span> <span class="kt">i64</span> <span class="o">%</span><span class="mi">1</span>
<span class="p">}</span>
</code></pre></div>



<a name="241094592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241094592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241094592">(Jun 02 2021 at 00:58)</a>:</h4>
<p>Rust regularly has worse tooling than the latest and greatest up and coming langs :( oh well, we got language features</p>



<a name="241094610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241094610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241094610">(Jun 02 2021 at 00:59)</a>:</h4>
<p>I don't buy that - you're compiler errors are a work of art!</p>



<a name="241094633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241094633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241094633">(Jun 02 2021 at 00:59)</a>:</h4>
<p>Julia's target has been that performance interactivity from the get-go though, so it tracks that it's so good.</p>



<a name="241095043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241095043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241095043">(Jun 02 2021 at 01:06)</a>:</h4>
<p>Alright, that should be good enough for now, if I can just verify that the proper assembly is emitted</p>



<a name="241095202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241095202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241095202">(Jun 02 2021 at 01:09)</a>:</h4>
<div class="codehilite" data-code-language="Bash"><pre><span></span><code> cargo rustc --release --example nbody -- --emit<span class="o">=</span>llvm-ir
</code></pre></div>



<a name="241095216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241095216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241095216">(Jun 02 2021 at 01:09)</a>:</h4>
<p>I'm trying that ^ and I still can't get the <code>llvm-ir</code> to be emmitted, or <code>asm</code></p>



<a name="241095231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241095231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241095231">(Jun 02 2021 at 01:09)</a>:</h4>
<p>If you grep <code>target</code> do you have any <code>.ll</code> files?</p>



<a name="241095307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241095307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241095307">(Jun 02 2021 at 01:11)</a>:</h4>
<p>Only some produced by <code>num_traits</code></p>



<a name="241095521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241095521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241095521">(Jun 02 2021 at 01:14)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> didn't you have a trick for getting <code>core_simd</code> in the Rust Playground to emit asm/llvm-ir?</p>



<a name="241096081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241096081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241096081">(Jun 02 2021 at 01:22)</a>:</h4>
<p><span class="user-mention silent" data-user-id="246783">Miguel Raz Guzmán Macedo</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/241095521">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> didn't you have a trick for getting <code>core_simd</code> in the Rust Playground to emit asm/llvm-ir?</p>
</blockquote>
<p>the <code>..</code> button next to <code>Run</code></p>



<a name="241096102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241096102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241096102">(Jun 02 2021 at 01:23)</a>:</h4>
<p>Do you have a MWE? My imports are borked here.</p>



<a name="241096219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241096219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241096219">(Jun 02 2021 at 01:25)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=791999c26a2850e5b91b069ab21849db">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=791999c26a2850e5b91b069ab21849db</a></p>



<a name="241096539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241096539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241096539">(Jun 02 2021 at 01:30)</a>:</h4>
<p>it's not gonna work.</p>



<a name="241097983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241097983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241097983">(Jun 02 2021 at 01:57)</a>:</h4>
<p>the playground only uses the top 100 crates on <a href="http://crates.io">crates.io</a> ^^;</p>



<a name="241099522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241099522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241099522">(Jun 02 2021 at 02:32)</a>:</h4>
<p><em>flashes his "two crates in the playground" medal</em></p>



<a name="241099949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241099949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241099949">(Jun 02 2021 at 02:42)</a>:</h4>
<p>Ah shucks.</p>



<a name="241099953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241099953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241099953">(Jun 02 2021 at 02:42)</a>:</h4>
<p>Oh grats <span class="user-mention" data-user-id="224471">@Lokathor</span></p>



<a name="241099959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241099959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241099959">(Jun 02 2021 at 02:43)</a>:</h4>
<p>Alright. Back to poking cargo till it spits out assembly.</p>



<a name="241099964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241099964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241099964">(Jun 02 2021 at 02:43)</a>:</h4>
<p>But tomorrow.</p>



<a name="241100066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241100066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241100066">(Jun 02 2021 at 02:45)</a>:</h4>
<p>the secret is to make very low level utility crates and then get them into everything, watch that daily download count skyrocket to the moon like GameStop.</p>



<a name="241109475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241109475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241109475">(Jun 02 2021 at 06:18)</a>:</h4>
<p>stuff used in the rust cookbook <a href="https://rust-lang-nursery.github.io/rust-cookbook/">https://rust-lang-nursery.github.io/rust-cookbook/</a> is also on the playground, but you have to be able to justify inclusion in the cookbook somewhat.</p>



<a name="241165211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241165211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241165211">(Jun 02 2021 at 15:24)</a>:</h4>
<p>Alright, if anyone can help verify that the current PR does simdify the hot loop appropriately it's ready to merge.</p>



<a name="241303222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241303222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241303222">(Jun 02 2021 at 18:53)</a>:</h4>
<p>Also totally off-topic but if anyone wants to read a super WIP blog post on going from Julia to Rust here is my entry so far: <a href="https://miguelraz.github.io/blog/juliatorust/">https://miguelraz.github.io/blog/juliatorust/</a></p>



<a name="241306050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241306050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241306050">(Jun 02 2021 at 19:15)</a>:</h4>
<p>Alright I'm starting the <code>dot_product.rs</code> benchmark.</p>



<a name="241306122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241306122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241306122">(Jun 02 2021 at 19:16)</a>:</h4>
<p>What's the difference between <code>&amp;[f32]</code> and <code>[f32; 4])</code> here?</p>



<a name="241306149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241306149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241306149">(Jun 02 2021 at 19:16)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="c1">// Code taken from the `packed_simd` crate</span>
<span class="c1">// Run this code with `cargo test --example dot_product`</span>
<span class="k">use</span><span class="w"> </span><span class="n">core_simd</span>::<span class="o">*</span><span class="p">;</span><span class="w"></span>

<span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">dot_prod</span><span class="p">(</span><span class="n">a</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="kt">f32</span><span class="p">],</span><span class="w"> </span><span class="n">b</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="kt">f32</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="kt">f32</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="fm">assert_eq!</span><span class="p">(</span><span class="n">a</span><span class="p">.</span><span class="n">len</span><span class="p">(),</span><span class="w"> </span><span class="n">b</span><span class="p">.</span><span class="n">len</span><span class="p">());</span><span class="w"></span>
<span class="w">    </span><span class="fm">assert!</span><span class="p">(</span><span class="n">a</span><span class="p">.</span><span class="n">len</span><span class="p">()</span><span class="w"> </span><span class="o">%</span><span class="w"> </span><span class="mi">4</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span><span class="w"></span>

<span class="w">    </span><span class="n">a</span><span class="p">.</span><span class="n">chunks_exact</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">map</span><span class="p">(</span><span class="n">f32x4</span>::<span class="n">from_array</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">zip</span><span class="p">(</span><span class="n">b</span><span class="p">.</span><span class="n">chunks_exact</span><span class="p">(</span><span class="mi">4</span><span class="p">).</span><span class="n">map</span><span class="p">(</span><span class="n">f32x4</span>::<span class="n">from_array</span><span class="p">))</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">map</span><span class="p">(</span><span class="o">|</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="n">b</span><span class="p">)</span><span class="o">|</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">b</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">sum</span><span class="p">()</span><span class="w"></span>
<span class="w">        </span><span class="c1">//.sum::&lt;f32x4&gt;()</span>
<span class="w">        </span><span class="p">.</span><span class="n">horizontal_sum</span><span class="p">()</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="c1">// Empty main to make cargo happy</span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[cfg(test)]</span><span class="w"></span>
<span class="k">mod</span> <span class="nn">tests</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="cp">#[test]</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">test</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">a</span>: <span class="nb">Vec</span><span class="o">&lt;</span><span class="kt">f32</span><span class="o">&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="fm">vec!</span><span class="p">[</span><span class="mf">1.0</span><span class="p">,</span><span class="w"> </span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="mf">3.0</span><span class="p">,</span><span class="w"> </span><span class="mf">4.0</span><span class="p">,</span><span class="w"> </span><span class="mf">5.0</span><span class="p">,</span><span class="w"> </span><span class="mf">6.0</span><span class="p">,</span><span class="w"> </span><span class="mf">7.0</span><span class="p">,</span><span class="w"> </span><span class="mf">8.0</span><span class="p">];</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">b</span>: <span class="nb">Vec</span><span class="o">&lt;</span><span class="kt">f32</span><span class="o">&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="fm">vec!</span><span class="p">[</span><span class="o">-</span><span class="mf">8.0</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mf">7.0</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mf">6.0</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mf">5.0</span><span class="p">,</span><span class="w"> </span><span class="mf">4.0</span><span class="p">,</span><span class="w"> </span><span class="mf">3.0</span><span class="p">,</span><span class="w"> </span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="mf">1.0</span><span class="p">];</span><span class="w"></span>

<span class="w">    </span><span class="fm">assert_eq!</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span><span class="w"> </span><span class="n">dot_prod</span><span class="p">(</span><span class="o">&amp;</span><span class="n">a</span><span class="p">,</span><span class="o">&amp;</span><span class="n">b</span><span class="p">));</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="241306164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241306164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241306164">(Jun 02 2021 at 19:16)</a>:</h4>
<p>Because rustc complains that:</p>



<a name="241306196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241306196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241306196">(Jun 02 2021 at 19:16)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">error</span><span class="p">[</span><span class="n">E0631</span><span class="p">]</span>: <span class="nc">type</span><span class="w"> </span><span class="n">mismatch</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">function</span><span class="w"> </span><span class="n">arguments</span><span class="w"></span>
<span class="w">  </span><span class="o">-</span>-&gt; <span class="nc">crates</span><span class="o">/</span><span class="n">core_simd</span><span class="o">/</span><span class="n">examples</span><span class="o">/</span><span class="n">dot_product</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">10</span>:<span class="mi">14</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w"></span>
<span class="mi">10</span><span class="w"> </span><span class="o">|</span><span class="w">         </span><span class="p">.</span><span class="n">map</span><span class="p">(</span><span class="n">f32x4</span>::<span class="n">from_array</span><span class="p">)</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w">              </span><span class="o">^^^^^^^^^^^^^^^^^</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w">              </span><span class="o">|</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w">              </span><span class="n">expected</span><span class="w"> </span><span class="n">signature</span><span class="w"> </span><span class="n">of</span><span class="w"> </span><span class="err">`</span><span class="k">fn</span><span class="p">(</span><span class="o">&amp;</span><span class="p">[</span><span class="kt">f32</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="nc">_</span><span class="err">`</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w">              </span><span class="n">found</span><span class="w"> </span><span class="n">signature</span><span class="w"> </span><span class="n">of</span><span class="w"> </span><span class="err">`</span><span class="k">fn</span><span class="p">([</span><span class="kt">f32</span><span class="p">;</span><span class="w"> </span><span class="mi">4</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="nc">_</span><span class="err">`</span><span class="w"></span>

<span class="n">error</span><span class="p">[</span><span class="n">E0599</span><span class="p">]</span>: <span class="nc">the</span><span class="w"> </span><span class="n">method</span><span class="w"> </span><span class="err">`</span><span class="n">zip</span><span class="err">`</span><span class="w"> </span><span class="n">exists</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">struct</span> <span class="err">`</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">ChunksExact</span><span class="o">&lt;'</span><span class="nb">_</span><span class="p">,</span><span class="w"> </span><span class="kt">f32</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="k">fn</span><span class="p">([</span><span class="kt">f32</span><span class="p">;</span><span class="w"> </span><span class="mi">4</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="nc">SimdF32</span><span class="o">&lt;</span><span class="mi">4_</span><span class="k">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="n">SimdF32</span>::<span class="o">&lt;</span><span class="mi">4_</span><span class="k">usize</span><span class="o">&gt;</span>::<span class="n">from_array</span><span class="p">}</span><span class="o">&gt;</span><span class="err">`</span><span class="p">,</span><span class="w"> </span><span class="n">but</span><span class="w"> </span><span class="n">its</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">bounds</span><span class="w"> </span><span class="n">were</span><span class="w"> </span><span class="n">not</span><span class="w"> </span><span class="n">satisfied</span><span class="w"></span>
</code></pre></div>



<a name="241306260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241306260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241306260">(Jun 02 2021 at 19:17)</a>:</h4>
<p>I'm guessing that <code>f(&amp;[f32])</code> expects an array of floats, and <code>f([f32 ; 4])</code> expects an array of precisely 4 f32's.</p>



<a name="241306292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241306292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241306292">(Jun 02 2021 at 19:17)</a>:</h4>
<p>Original code is here if anyone wants to know <a href="https://github.com/rust-lang/packed_simd/blob/master/examples/dot_product/src/simd.rs">https://github.com/rust-lang/packed_simd/blob/master/examples/dot_product/src/simd.rs</a></p>



<a name="241306911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241306911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241306911">(Jun 02 2021 at 19:22)</a>:</h4>
<p>Nice blog post!</p>



<a name="241306982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241306982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241306982">(Jun 02 2021 at 19:22)</a>:</h4>
<p>Thanks <span class="user-mention" data-user-id="229517">@Jacob Lifshay</span> I don't think I know of many "Julia to Rust" guides so I might as well write up my learnings.</p>



<a name="241334797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241334797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241334797">(Jun 03 2021 at 00:01)</a>:</h4>
<p>ermahgerd I just found out about <code>cargo watch</code> from going through the rustlings again!</p>



<a name="241336917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241336917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241336917">(Jun 03 2021 at 00:37)</a>:</h4>
<p>Oooh, the Struct  update syntax constructor is neat!</p>



<a name="241339833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241339833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241339833">(Jun 03 2021 at 01:32)</a>:</h4>
<p>yes!</p>



<a name="241351771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241351771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241351771">(Jun 03 2021 at 06:09)</a>:</h4>
<p><span class="user-mention silent" data-user-id="246783">Miguel Raz Guzmán Macedo</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/241334797">said</a>:</p>
<blockquote>
<p>ermahgerd I just found out about <code>cargo watch</code> from going through the rustlings again!</p>
</blockquote>
<p>Oh yeah, watch is essential. Better than RA really.</p>



<a name="241404100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241404100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241404100">(Jun 03 2021 at 15:06)</a>:</h4>
<p>RA?</p>



<a name="241405364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241405364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241405364">(Jun 03 2021 at 15:14)</a>:</h4>
<p>Rust-Analyzer</p>



<a name="241447966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241447966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241447966">(Jun 03 2021 at 20:26)</a>:</h4>
<p>Alright - I redid the rustlings. Feeling a bit sharper with my Rust now. Still no big fights with the borrow checker but all is well.</p>



<a name="241447983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241447983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241447983">(Jun 03 2021 at 20:26)</a>:</h4>
<p>Anyone want to help me out with the code snippet above?</p>



<a name="241448977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241448977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241448977">(Jun 03 2021 at 20:36)</a>:</h4>
<p>or merge the <code>nbody</code> too.</p>



<a name="241458526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241458526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241458526">(Jun 03 2021 at 21:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="246783">Miguel Raz Guzmán Macedo</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/241306122">said</a>:</p>
<blockquote>
<p>What's the difference between <code>&amp;[f32]</code> and <code>[f32; 4])</code> here?</p>
</blockquote>
<blockquote>
<p>I'm guessing that <code>f(&amp;[f32])</code> expects an array of floats, and <code>f([f32 ; 4])</code> expects an array of precisely 4 f32's.</p>
</blockquote>
<p>Mostly correct. So, <code>&amp;[T]</code> is the signature for a slice. <code>[T; N]</code> is the signature for an array.</p>



<a name="241462351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241462351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241462351">(Jun 03 2021 at 22:06)</a>:</h4>
<p>(Minor terminology nitpick: technically <code>[T]</code> is a slice, so <code>&amp;[T]</code> expects a reference to a slice, like how <code>&amp;[T; N]</code> expects a reference to an array.  Conversationally, though, it is quite common to elide the "reference to" for DSTs, since they're nearly always mentioned under indirection.)</p>



<a name="241462774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241462774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241462774">(Jun 03 2021 at 22:09)</a>:</h4>
<p>This is true, because <code>&amp;mut [T]</code> is a mutable reference to a slice, yes.<br>
...does anything actually operate on <code>[T]</code> directly without first having indirection?</p>



<a name="241463128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241463128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241463128">(Jun 03 2021 at 22:12)</a>:</h4>
<p>They can be <em>mentioned</em> without indirection in things like <code>impl Index&lt;usize&gt; for [u32]</code> or <code>impl PartialOrd for str</code>.</p>
<p>Certainly in stable there's no way to <em>operate</em> on them directly, though.  (unsized-rvalues might allow it in some cases in nightly.)</p>



<a name="241470310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241470310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241470310">(Jun 03 2021 at 23:40)</a>:</h4>
<p>fair enough</p>



<a name="241470318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241470318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241470318">(Jun 03 2021 at 23:40)</a>:</h4>
<p>thanks for the input peeps</p>



<a name="241470382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241470382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241470382">(Jun 03 2021 at 23:41)</a>:</h4>
<p>...Still don't know how to make the code work.</p>



<a name="241470395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241470395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241470395">(Jun 03 2021 at 23:42)</a>:</h4>
<p>I'ld also ideally like to show a case where the array is not a neat mutliple of 4 and how to handle that</p>



<a name="241470441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241470441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241470441">(Jun 03 2021 at 23:42)</a>:</h4>
<p>I think <code>rchunks_mut_exact</code> is the way to go or something like that</p>



<a name="241472335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241472335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241472335">(Jun 04 2021 at 00:12)</a>:</h4>
<p>yeah but then you can't use a for loop</p>



<a name="241472344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241472344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241472344">(Jun 04 2021 at 00:12)</a>:</h4>
<p>you have to work the iterator manually, because a for loop consumes it</p>



<a name="241472433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241472433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241472433">(Jun 04 2021 at 00:14)</a>:</h4>
<p>so something like:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">iter</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">my_slice</span><span class="p">.</span><span class="n">chunks_exact_mut</span><span class="p">(</span><span class="mi">4</span><span class="p">);</span><span class="w"></span>
<span class="k">while</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="n">chunk</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">iter</span><span class="p">.</span><span class="n">next</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="c1">// use a chunk</span>
<span class="p">}</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">scrap</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">iter</span><span class="p">.</span><span class="n">into_remainder</span><span class="p">();</span><span class="w"></span>
<span class="c1">// handle the scrap</span>
</code></pre></div>



<a name="241473836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241473836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241473836">(Jun 04 2021 at 00:41)</a>:</h4>
<p>Since we're on nightly, it'd be totally legit to use <a href="https://doc.rust-lang.org/std/primitive.slice.html#method.array_chunks">https://doc.rust-lang.org/std/primitive.slice.html#method.array_chunks</a></p>



<a name="241477877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241477877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241477877">(Jun 04 2021 at 01:18)</a>:</h4>
<p>I always support <code>as_chunks</code> (or <code>as_rchunks</code> or <code>as_chunks_unchecked</code>) <span aria-label="smirk" class="emoji emoji-1f60f" role="img" title="smirk">:smirk:</span></p>



<a name="241478181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241478181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241478181">(Jun 04 2021 at 01:19)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="p">(</span><span class="n">chunks</span><span class="p">,</span><span class="w"> </span><span class="n">scrap</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">my_slice</span><span class="p">.</span><span class="n">as_chunks_mut</span><span class="p">();</span><span class="w"></span>
<span class="k">for</span><span class="w"> </span><span class="n">chunk</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">chunks</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="c1">// use a chunk</span>
<span class="p">}</span><span class="w"></span>
<span class="c1">// handle the scrap</span>
</code></pre></div>



<a name="241563007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241563007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241563007">(Jun 04 2021 at 16:48)</a>:</h4>
<p><span aria-label="tada" class="emoji emoji-1f389" role="img" title="tada">:tada:</span> 1 down, a few more to go <span aria-label="tada" class="emoji emoji-1f389" role="img" title="tada">:tada:</span></p>



<a name="241563014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241563014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241563014">(Jun 04 2021 at 16:48)</a>:</h4>
<p>Thanks for the merge <span class="user-mention" data-user-id="281757">@Jubilee</span></p>



<a name="241563767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241563767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241563767">(Jun 04 2021 at 16:54)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> I think you can click the box for <code>N-body</code> here now</p>



<a name="241564603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241564603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241564603">(Jun 04 2021 at 17:00)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> yeah my code is just looking... not pretty:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">dot_prod</span><span class="p">(</span><span class="n">a</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="kt">f32</span><span class="p">],</span><span class="w"> </span><span class="n">b</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="kt">f32</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="kt">f32</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="fm">assert_eq!</span><span class="p">(</span><span class="n">a</span><span class="p">.</span><span class="n">len</span><span class="p">(),</span><span class="w"> </span><span class="n">b</span><span class="p">.</span><span class="n">len</span><span class="p">());</span><span class="w"></span>

<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">iter</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">a</span><span class="p">.</span><span class="n">chunks_exact_mut</span><span class="p">(</span><span class="mi">4</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="k">while</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="n">chunk</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">iter</span><span class="p">.</span><span class="n">next</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">iter2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">b</span><span class="p">.</span><span class="n">chunks_exact_mut</span><span class="p">(</span><span class="mi">4</span><span class="p">).</span><span class="n">next</span><span class="p">();</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">a_simd</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">f32x4</span>::<span class="n">from_array</span><span class="p">(</span><span class="n">chunk</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">b_simd</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">f32x4</span>::<span class="n">from_array</span><span class="p">(</span><span class="n">iter2</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="c1">//...</span>

<span class="w">    </span><span class="p">}</span><span class="w"></span>

<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="241565747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241565747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241565747">(Jun 04 2021 at 17:07)</a>:</h4>
<p>checked off!</p>



<a name="241566478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241566478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241566478">(Jun 04 2021 at 17:13)</a>:</h4>
<p><span class="user-mention" data-user-id="246783">@Miguel Raz Guzmán Macedo</span> Iterators are, as mentioned, library code, with the caveat that the Rust <code>std</code> is allowed to internally use certain special features which are not fully implemented in the language yet, because it doesn't expose those to public APIs.</p>



<a name="241566675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241566675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241566675">(Jun 04 2021 at 17:15)</a>:</h4>
<p>So if you have a Vec that you call IntoIterator on, and then call a bunch of methods on it that would skip around and iterate over certain sections of it, Rust has certain unsafe traits like TrustedLen and TrustedRandomAccess implemented on Vec which allow it to just have the iteration jump ahead and operate in that way, and LLVM then carries it the rest of the way in optimization.</p>



<a name="241566754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241566754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241566754">(Jun 04 2021 at 17:16)</a>:</h4>
<p>TrustedLen is publicly implementable IIRC but you can't do that with TrustedRandomAccess.</p>



<a name="241567033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241567033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241567033">(Jun 04 2021 at 17:18)</a>:</h4>
<p>and you have one of the occasional library warts in that technically TRA exposes a sealed method that is marked <code>__iterator_get_unchecked</code> <span aria-label="grimacing" class="emoji emoji-1f62c" role="img" title="grimacing">:grimacing:</span></p>



<a name="241567790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241567790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241567790">(Jun 04 2021 at 17:24)</a>:</h4>
<p>btw, anyone know how to get <code>examples/dot_product.rs</code> to work with <code>cargo watch</code>?</p>



<a name="241570726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241570726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241570726">(Jun 04 2021 at 17:48)</a>:</h4>
<p>you probably want to be using<br>
<code>cargo watch -c -x "run --examples dot_product"</code></p>



<a name="241570753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241570753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241570753">(Jun 04 2021 at 17:48)</a>:</h4>
<p>-c is optional i just like it for clarity</p>



<a name="241571169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241571169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241571169">(Jun 04 2021 at 17:51)</a>:</h4>
<p>Gotcha, lemme try.</p>



<a name="241571225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241571225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241571225">(Jun 04 2021 at 17:52)</a>:</h4>
<p>oooh, nice call on the <code>-c</code>. Lemme add it to the diary.</p>



<a name="241572648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241572648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241572648">(Jun 04 2021 at 18:03)</a>:</h4>
<p>Thanks! Do you mind being credited as <code>Lokathor</code> on the diary <span class="user-mention" data-user-id="224471">@Lokathor</span> ?</p>



<a name="241573565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241573565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241573565">(Jun 04 2021 at 18:11)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/241472433">said</a>:</p>
<blockquote>
<p>so something like:</p>
<p><div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">iter</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">my_slice</span><span class="p">.</span><span class="n">chunks_exact_mut</span><span class="p">(</span><span class="mi">4</span><span class="p">);</span><span class="w"></span>
<span class="k">while</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="n">chunk</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">iter</span><span class="p">.</span><span class="n">next</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="c1">// use a chunk</span>
<span class="p">}</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">scrap</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">iter</span><span class="p">.</span><span class="n">into_remainder</span><span class="p">();</span><span class="w"></span>
<span class="c1">// handle the scrap</span>
</code></pre></div><br>
</p>
</blockquote>
<p>I'm really trying to rewrite the example to use this with iterators but I'm coming up blank.</p>



<a name="241573704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241573704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241573704">(Jun 04 2021 at 18:12)</a>:</h4>
<p>yeah Lokathor is fine</p>



<a name="241573717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241573717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241573717">(Jun 04 2021 at 18:12)</a>:</h4>
<p>and you're already using iterators!</p>



<a name="241573843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241573843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241573843">(Jun 04 2021 at 18:13)</a>:</h4>
<p>yeah but look at this neat code I'm trying to port</p>



<a name="241573935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241573935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241573935">(Jun 04 2021 at 18:14)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">dot_prod</span><span class="p">(</span><span class="n">a</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="kt">f32</span><span class="p">],</span><span class="w"> </span><span class="n">b</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="kt">f32</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="kt">f32</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="fm">assert_eq!</span><span class="p">(</span><span class="n">a</span><span class="p">.</span><span class="n">len</span><span class="p">(),</span><span class="w"> </span><span class="n">b</span><span class="p">.</span><span class="n">len</span><span class="p">());</span><span class="w"></span>
<span class="w">    </span><span class="fm">assert!</span><span class="p">(</span><span class="n">a</span><span class="p">.</span><span class="n">len</span><span class="p">()</span><span class="w"> </span><span class="o">%</span><span class="w"> </span><span class="mi">4</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span><span class="w"></span>

<span class="w">    </span><span class="n">a</span><span class="p">.</span><span class="n">chunks_exact</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">map</span><span class="p">(</span><span class="n">f32x4</span>::<span class="n">from_slice_unaligned</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">zip</span><span class="p">(</span><span class="n">b</span><span class="p">.</span><span class="n">chunks_exact</span><span class="p">(</span><span class="mi">4</span><span class="p">).</span><span class="n">map</span><span class="p">(</span><span class="n">f32x4</span>::<span class="n">from_slice_unaligned</span><span class="p">))</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">map</span><span class="p">(</span><span class="o">|</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="p">)</span><span class="o">|</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">b</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">sum</span>::<span class="o">&lt;</span><span class="n">f32x4</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">sum</span><span class="p">()</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="241574000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241574000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241574000">(Jun 04 2021 at 18:15)</a>:</h4>
<p>...and the <code>f32x4::from_slice_unaligned</code> is not something I can easily <code>map</code></p>



<a name="241575354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241575354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241575354">(Jun 04 2021 at 18:27)</a>:</h4>
<p>I think the problem is that I want to convert from a slice which I know has a fixed size to an array.</p>



<a name="241575970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241575970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241575970">(Jun 04 2021 at 18:32)</a>:</h4>
<p><code>.array_chunks::&lt;4&gt;</code></p>



<a name="241576655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241576655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241576655">(Jun 04 2021 at 18:38)</a>:</h4>
<p>Sorry for the handholding, but do you mean like this?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">dot_prod</span><span class="p">(</span><span class="n">a</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="kt">f32</span><span class="p">],</span><span class="w"> </span><span class="n">b</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="kt">f32</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="kt">f32</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="fm">assert_eq!</span><span class="p">(</span><span class="n">a</span><span class="p">.</span><span class="n">len</span><span class="p">(),</span><span class="w"> </span><span class="n">b</span><span class="p">.</span><span class="n">len</span><span class="p">());</span><span class="w"></span>

<span class="cp">#[feature(array_chunks)]</span><span class="w"></span>
<span class="w">    </span><span class="n">a</span><span class="p">.</span><span class="n">array_chunks</span>::<span class="o">&lt;</span><span class="mi">4</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">map</span><span class="p">(</span><span class="n">f32x4</span>::<span class="n">from_array</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">zip</span><span class="p">(</span><span class="n">b</span><span class="p">.</span><span class="n">array_chunks</span>::<span class="o">&lt;</span><span class="mi">4</span><span class="o">&gt;</span><span class="p">().</span><span class="n">map</span><span class="p">(</span><span class="n">f32x4</span>::<span class="n">from_array</span><span class="p">))</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">map</span><span class="p">(</span><span class="o">|</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="n">b</span><span class="p">)</span><span class="o">|</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">b</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">sum</span><span class="p">()</span><span class="w"></span>
<span class="w">        </span><span class="c1">//.sum::&lt;f32x4&gt;()</span>
<span class="w">        </span><span class="p">.</span><span class="n">horizontal_sum</span><span class="p">()</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>Because otherwise I didn't get how to map that to the chunks.</p>



<a name="241576710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241576710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241576710">(Jun 04 2021 at 18:38)</a>:</h4>
<p>yes!</p>



<a name="241576804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241576804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241576804">(Jun 04 2021 at 18:39)</a>:</h4>
<p>Rust has complained, and loudly:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w"> </span><span class="o">-</span>-&gt; <span class="nc">crates</span><span class="o">/</span><span class="n">core_simd</span><span class="o">/</span><span class="n">examples</span><span class="o">/</span><span class="n">dot_product</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">9</span>:<span class="mi">7</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w"></span>
<span class="mi">9</span><span class="w"> </span><span class="o">|</span><span class="w">     </span><span class="n">a</span><span class="p">.</span><span class="n">array_chunks</span>::<span class="o">&lt;</span><span class="mi">4</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w">       </span><span class="o">^^^^^^^^^^^^</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w"></span>
<span class="w">  </span><span class="o">=</span><span class="w"> </span><span class="n">note</span>: <span class="nc">see</span><span class="w"> </span><span class="n">issue</span><span class="w"> </span>#<span class="mi">74985</span><span class="w"> </span><span class="o">&lt;</span><span class="n">https</span>:<span class="c1">//github.com/rust-lang/rust/issues/74985&gt; for more information</span>
<span class="w">  </span><span class="o">=</span><span class="w"> </span><span class="n">help</span>: <span class="nc">add</span><span class="w"> </span><span class="err">`</span><span class="cp">#![feature(array_chunks)]</span><span class="err">`</span><span class="w"> </span><span class="n">to</span><span class="w"> </span><span class="n">the</span><span class="w"> </span><span class="k">crate</span><span class="w"> </span><span class="n">attributes</span><span class="w"> </span><span class="n">to</span><span class="w"> </span><span class="n">enable</span><span class="w"></span>
</code></pre></div>



<a name="241576903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241576903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241576903">(Jun 04 2021 at 18:40)</a>:</h4>
<p>yes, you need to add it at the crate level. ^^;</p>



<a name="241576958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241576958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241576958">(Jun 04 2021 at 18:40)</a>:</h4>
<p>Ok, will do, but this also happens </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">ype</span><span class="w"> </span><span class="n">mismatch</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">function</span><span class="w"> </span><span class="n">arguments</span><span class="w"></span>
<span class="w">  </span><span class="o">-</span>-&gt; <span class="nc">crates</span><span class="o">/</span><span class="n">core_simd</span><span class="o">/</span><span class="n">examples</span><span class="o">/</span><span class="n">dot_product</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">10</span>:<span class="mi">14</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w"></span>
<span class="mi">10</span><span class="w"> </span><span class="o">|</span><span class="w">         </span><span class="p">.</span><span class="n">map</span><span class="p">(</span><span class="o">&amp;</span><span class="n">f32x4</span>::<span class="n">from_array</span><span class="p">)</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w">              </span><span class="o">^^^^^^^^^^^^^^^^^^</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w">              </span><span class="o">|</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w">              </span><span class="n">expected</span><span class="w"> </span><span class="n">signature</span><span class="w"> </span><span class="n">of</span><span class="w"> </span><span class="err">`</span><span class="k">fn</span><span class="p">(</span><span class="o">&amp;</span><span class="p">[</span><span class="kt">f32</span><span class="p">;</span><span class="w"> </span><span class="mi">4</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="nc">_</span><span class="err">`</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w">              </span><span class="n">found</span><span class="w"> </span><span class="n">signature</span><span class="w"> </span><span class="n">of</span><span class="w"> </span><span class="err">`</span><span class="k">fn</span><span class="p">([</span><span class="kt">f32</span><span class="p">;</span><span class="w"> </span><span class="mi">4</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="nc">_</span><span class="err">`</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w"></span>
<span class="w">   </span><span class="o">=</span><span class="w"> </span><span class="n">note</span>: <span class="nc">required</span><span class="w"> </span><span class="n">because</span><span class="w"> </span><span class="n">of</span><span class="w"> </span><span class="n">the</span><span class="w"> </span><span class="n">requirements</span><span class="w"> </span><span class="n">on</span><span class="w"> </span><span class="n">the</span><span class="w"> </span><span class="k">impl</span><span class="w"> </span><span class="n">of</span><span class="w"> </span><span class="err">`</span><span class="nb">FnMut</span><span class="o">&lt;</span><span class="p">(</span><span class="o">&amp;</span><span class="p">[</span><span class="kt">f32</span><span class="p">;</span><span class="w"> </span><span class="mi">4</span><span class="p">],)</span><span class="o">&gt;</span><span class="err">`</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="err">`</span><span class="o">&amp;</span><span class="k">fn</span><span class="p">([</span><span class="kt">f32</span><span class="p">;</span><span class="w"> </span><span class="mi">4</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="nc">SimdF32</span><span class="o">&lt;</span><span class="mi">4_</span><span class="k">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="n">SimdF32</span>::<span class="o">&lt;</span><span class="mi">4_</span><span class="k">usize</span><span class="o">&gt;</span>::<span class="n">from_array</span><span class="p">}</span><span class="err">`</span><span class="w"></span>
</code></pre></div>



<a name="241577003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241577003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241577003">(Jun 04 2021 at 18:41)</a>:</h4>
<p>lol</p>



<a name="241577090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241577090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241577090">(Jun 04 2021 at 18:41)</a>:</h4>
<p><code>.map(|a| f32x4::from_array(a))</code><br>
should work, or else <code>.map(|a| f32x4::from_array(&amp;a))</code></p>



<a name="241577164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241577164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241577164">(Jun 04 2021 at 18:42)</a>:</h4>
<p>Ok</p>



<a name="241577245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241577245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241577245">(Jun 04 2021 at 18:43)</a>:</h4>
<p>Also, how should I add that at the crate level? Do I create a <code>Cargo.toml</code> entry like</p>
<div class="codehilite" data-code-language="TOML"><pre><span></span><code><span class="k">[features]</span>
<span class="n">default</span> <span class="o">=</span> <span class="k">["std"]</span>
<span class="n">std</span> <span class="o">=</span> <span class="k">[]</span>
<span class="n">array_chunks</span> <span class="o">=</span> <span class="n">true</span> <span class="c1"># ?</span>
</code></pre></div>



<a name="241577385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241577385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241577385">(Jun 04 2021 at 18:44)</a>:</h4>
<p>Alright, the <code>map</code> stuff seemd to work, thanks Jubilee.</p>



<a name="241577390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241577390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241577390">(Jun 04 2021 at 18:44)</a>:</h4>
<p>brb food.</p>



<a name="241577452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241577452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241577452">(Jun 04 2021 at 18:45)</a>:</h4>
<p>ah no, so like, it has to be seen by rustc, and rustc doesn't see Cargo.toml per se.<br>
you want the crate's first file, and you want to add <code>#![feature(array_chunks)]</code><br>
<code>#!</code> is an "inner" attribute, it adds to whatever it is <em>inside</em> of.</p>



<a name="241579725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241579725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241579725">(Jun 04 2021 at 19:04)</a>:</h4>
<p>Ok, I guess the first file is <code>main.rs</code>/<code>lib.rs</code>.</p>



<a name="241579736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241579736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241579736">(Jun 04 2021 at 19:04)</a>:</h4>
<p>Oh, and I'm guessing because we're on <code>nightly</code> we don't mind adding this feature flag right?</p>



<a name="241580499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241580499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241580499">(Jun 04 2021 at 19:11)</a>:</h4>
<p>Hmmm - adding the <code>#![feature(array_chunks)]</code> in <code>src/lib.rs</code> still gives errros:</p>



<a name="241580508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241580508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241580508">(Jun 04 2021 at 19:11)</a>:</h4>
<p>I believe the example is its own crate.</p>



<a name="241580600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241580600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241580600">(Jun 04 2021 at 19:12)</a>:</h4>
<p>mmmm nope - they're standalone files in <code>examples/</code></p>



<a name="241580627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241580627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241580627">(Jun 04 2021 at 19:12)</a>:</h4>
<p>Should it be a standalone crate? <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="241580629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241580629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241580629">(Jun 04 2021 at 19:12)</a>:</h4>
<p>That doesn't mean they aren't logically their own crate.</p>



<a name="241580640"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241580640" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241580640">(Jun 04 2021 at 19:12)</a>:</h4>
<p>Oh, right.</p>



<a name="241580679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241580679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241580679">(Jun 04 2021 at 19:13)</a>:</h4>
<p>"crate" is Rust's concept of a code generation unit, basically.</p>



<a name="241580741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241580741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241580741">(Jun 04 2021 at 19:13)</a>:</h4>
<p>ah right - I thought it was teh concrete files generate by <code>cargo new foo</code>.</p>



<a name="241580812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241580812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241580812">(Jun 04 2021 at 19:14)</a>:</h4>
<p>Ok, a top level <code>#![feature(array_chunks)]</code> seems to have done it for now. Thanks!</p>



<a name="241581450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241581450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241581450">(Jun 04 2021 at 19:21)</a>:</h4>
<p>HUZZAHH it passes tests <span aria-label="tada" class="emoji emoji-1f389" role="img" title="tada">:tada:</span></p>



<a name="241582997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241582997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241582997">(Jun 04 2021 at 19:35)</a>:</h4>
<p>Alright... I think now's just about a good time to learn the business with those shuffles as any other. <code>matrix_inversion</code> is next!</p>



<a name="241586418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241586418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241586418">(Jun 04 2021 at 20:03)</a>:</h4>
<p>uuuuh I think we need some docs on this one <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="241587245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241587245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241587245">(Jun 04 2021 at 20:10)</a>:</h4>
<p>How does this work again?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="k">fn</span> <span class="nf">shuffle</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">use</span><span class="w"> </span><span class="k">super</span>::<span class="o">*</span><span class="p">;</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">SimdF32</span>::<span class="n">from_array</span><span class="p">([</span><span class="mf">1.0</span><span class="p">,</span><span class="w"> </span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="mf">3.0</span><span class="p">,</span><span class="w"> </span><span class="mf">4.0</span><span class="p">]);</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">b</span><span class="w"> </span><span class="o">=</span><span class="w">  </span><span class="n">SimdF32</span>::<span class="n">from_array</span><span class="p">([</span><span class="mf">5.0</span><span class="p">,</span><span class="w"> </span><span class="mf">6.0</span><span class="p">,</span><span class="w"> </span><span class="mf">7.0</span><span class="p">,</span><span class="w"> </span><span class="mf">8.0</span><span class="p">]);</span><span class="w"></span>

<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">shuffle</span>::<span class="o">&lt;</span><span class="p">[</span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="mi">7</span><span class="p">]</span><span class="o">&gt;</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="n">b</span><span class="p">);</span><span class="w"></span>

<span class="w">      </span><span class="c1">// ???</span>
<span class="w">      </span><span class="fm">assert_eq!</span><span class="p">(</span><span class="n">SimdF32</span>::<span class="n">from_array</span><span class="p">([</span><span class="mf">5.0</span><span class="p">,</span><span class="w"> </span><span class="mf">1.0</span><span class="p">,</span><span class="w"> </span><span class="mf">4.0</span><span class="p">,</span><span class="w"> </span><span class="mf">8.0</span><span class="p">]),</span><span class="w"> </span><span class="n">c</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="241588501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241588501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241588501">(Jun 04 2021 at 20:22)</a>:</h4>
<p>that looks correct, at a glance?</p>



<a name="241588646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241588646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241588646">(Jun 04 2021 at 20:24)</a>:</h4>
<p>Nah, this is good now:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="cp">#[test]</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">shuffle_test</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">use</span><span class="w"> </span><span class="k">super</span>::<span class="o">*</span><span class="p">;</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">SimdF32</span>::<span class="n">from_array</span><span class="p">([</span><span class="mf">1.0</span><span class="p">,</span><span class="w"> </span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="mf">3.0</span><span class="p">,</span><span class="w"> </span><span class="mf">4.0</span><span class="p">]);</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">b</span><span class="w"> </span><span class="o">=</span><span class="w">  </span><span class="n">SimdF32</span>::<span class="n">from_array</span><span class="p">([</span><span class="mf">5.0</span><span class="p">,</span><span class="w"> </span><span class="mf">6.0</span><span class="p">,</span><span class="w"> </span><span class="mf">7.0</span><span class="p">,</span><span class="w"> </span><span class="mf">8.0</span><span class="p">]);</span><span class="w"></span>

<span class="w">        </span><span class="k">const</span><span class="w"> </span><span class="n">IDXS</span>: <span class="p">[</span><span class="kt">u32</span><span class="p">;</span><span class="w"> </span><span class="mi">4</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mi">4</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">7</span><span class="p">];</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">SimdF32</span>::<span class="o">&lt;</span><span class="mi">4</span><span class="o">&gt;</span>::<span class="n">shuffle</span>::<span class="o">&lt;</span><span class="n">IDXS</span><span class="o">&gt;</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="n">b</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="fm">assert_eq!</span><span class="p">(</span><span class="n">SimdF32</span>::<span class="n">from_array</span><span class="p">([</span><span class="mf">5.0</span><span class="p">,</span><span class="w"> </span><span class="mf">1.0</span><span class="p">,</span><span class="w"> </span><span class="mf">4.0</span><span class="p">,</span><span class="w"> </span><span class="mf">8.0</span><span class="p">]),</span><span class="w"> </span><span class="n">c</span><span class="p">);</span><span class="w"></span>

<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="241588727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241588727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241588727">(Jun 04 2021 at 20:25)</a>:</h4>
<p>With the <code>SimdF32::&lt;4&gt; -&gt; f32x4</code> swapping, all is good.</p>



<a name="241589570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241589570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241589570">(Jun 04 2021 at 20:34)</a>:</h4>
<p>Doctests PR made! <a href="https://github.com/rust-lang/stdsimd/pull/130">https://github.com/rust-lang/stdsimd/pull/130</a></p>



<a name="241590049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241590049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241590049">(Jun 04 2021 at 20:38)</a>:</h4>
<p>oh right.</p>



<a name="241590766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241590766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241590766">(Jun 04 2021 at 20:45)</a>:</h4>
<p>What's the easiest way to avoid writing <code>const foo ... = [ ...]</code> everywhere?</p>



<a name="241590783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241590783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241590783">(Jun 04 2021 at 20:45)</a>:</h4>
<p>I have this I need to work through</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">tmp1</span>: <span class="nc">f32x4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">f32x4</span>::<span class="n">shuffle</span>::<span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="mi">5</span><span class="p">]</span><span class="o">&gt;</span><span class="p">(</span><span class="n">m_0</span><span class="p">,</span><span class="w"> </span><span class="n">m_1</span><span class="p">);</span><span class="w"></span>
</code></pre></div>



<a name="241590977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241590977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241590977">(Jun 04 2021 at 20:47)</a>:</h4>
<p>try <code>&lt;{ [0, 1, 4, 5] }&gt;</code>?</p>



<a name="241591333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241591333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241591333">(Jun 04 2021 at 20:50)</a>:</h4>
<p>Oh neat.</p>



<a name="241591389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241591389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241591389">(Jun 04 2021 at 20:51)</a>:</h4>
<p>What about for this one?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="c1">// let m_1 = f32x4::from_slice_unaligned(&amp;m[1]);</span>
</code></pre></div>
<p>tyring to get it to be</p>



<a name="241591410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241591410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241591410">(Jun 04 2021 at 20:51)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">m_1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">f32x4</span>::<span class="n">from_array</span><span class="p">(</span><span class="o">&amp;</span><span class="n">m</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="n">array_chunks</span>::<span class="o">&lt;</span><span class="mi">4</span><span class="o">&gt;</span><span class="p">());</span><span class="w"></span>
</code></pre></div>



<a name="241591872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241591872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241591872">(Jun 04 2021 at 20:55)</a>:</h4>
<p>answered my own question:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">m_1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">f32x4</span>::<span class="n">from_array</span><span class="p">(</span><span class="n">m</span><span class="p">[</span><span class="mi">1</span><span class="p">]);</span><span class="w"></span>
</code></pre></div>



<a name="241591884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241591884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241591884">(Jun 04 2021 at 20:55)</a>:</h4>
<p><span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="241596379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241596379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241596379">(Jun 04 2021 at 21:41)</a>:</h4>
<p>TESTS PASS WASSUP<br>
<a href="https://github.com/rust-lang/stdsimd/pull/131">https://github.com/rust-lang/stdsimd/pull/131</a></p>



<a name="241596397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241596397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241596397">(Jun 04 2021 at 21:41)</a>:</h4>
<p><span aria-label="rocket" class="emoji emoji-1f680" role="img" title="rocket">:rocket:</span> <span aria-label="rocket" class="emoji emoji-1f680" role="img" title="rocket">:rocket:</span> <span aria-label="rocket" class="emoji emoji-1f680" role="img" title="rocket">:rocket:</span></p>



<a name="241603146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241603146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241603146">(Jun 04 2021 at 23:19)</a>:</h4>
<p>(deleted)</p>



<a name="241605714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241605714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241605714">(Jun 05 2021 at 00:05)</a>:</h4>
<p>Oooh, <code>cargo test --doc</code> is super neat!</p>



<a name="241605728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241605728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241605728">(Jun 05 2021 at 00:05)</a>:</h4>
<p>Would anyone be opposed if I added a bunch of doctests that showed example usage of <code>lanes_eq</code> + friends and a bunch of other functions?</p>



<a name="241610628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241610628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241610628">(Jun 05 2021 at 02:15)</a>:</h4>
<p>go ahead imo!</p>



<a name="241611684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241611684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241611684">(Jun 05 2021 at 02:43)</a>:</h4>
<p>Awesome.</p>



<a name="241611688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241611688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241611688">(Jun 05 2021 at 02:43)</a>:</h4>
<p>Hey, if anyone wants to comment on my Rust learnings, by blog post is almost done - I'd appreciate any feedback <a href="https://miguelraz.github.io/blog/juliatorust/">https://miguelraz.github.io/blog/juliatorust/</a></p>



<a name="241612845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241612845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241612845">(Jun 05 2021 at 03:17)</a>:</h4>
<p>So this is an enormously esoteric nit but... Rust does not have linear types.<br>
It has affine types!<br>
The difference is "must use once" vs. "must use no more than once".<br>
<a href="https://gankra.github.io/blah/linear-rust/">https://gankra.github.io/blah/linear-rust/</a></p>



<a name="241614699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241614699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241614699">(Jun 05 2021 at 04:10)</a>:</h4>
<blockquote>
<p>(which means an automatic RC garbage collector and no threading run time) </p>
</blockquote>
<p>also we technically don't even have reference counting garbage collection, we use "region-based memory management". <a href="https://en.wikipedia.org/wiki/Region-based_memory_management">https://en.wikipedia.org/wiki/Region-based_memory_management</a><br>
except with explicit use of the Rc and Arc types. <a href="https://doc.rust-lang.org/std/rc/index.html">https://doc.rust-lang.org/std/rc/index.html</a><br>
unlike, say, Python, which always did implicitly reference count things.</p>
<blockquote>
<p>they developed this library as external to stdlib. There's several social and technical constraints for why Tokio is not always included, like embedded systems and people who want to work on no stdlib environments.</p>
</blockquote>
<p>Well, specifically, in <code>#![no_std]</code> code you don't even have <em>allocation</em> as a guaranteed thing. No Vec. Most runtimes require some std feature. Rust could also offer sufficiently tools to abstract over the points that are shared between executors, but we haven't yet.</p>



<a name="241615257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241615257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241615257">(Jun 05 2021 at 04:26)</a>:</h4>
<p>Awesome - I'l patch that up.</p>



<a name="241615396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241615396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241615396">(Jun 05 2021 at 04:31)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/241610628">said</a>:</p>
<blockquote>
<p>go ahead imo!</p>
</blockquote>
<p>Awesome, I have goals for tomorrow.</p>



<a name="241636595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241636595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241636595">(Jun 05 2021 at 13:26)</a>:</h4>
<p>Anyone have a small but not trivial use case for simd masks?</p>



<a name="241637448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241637448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241637448">(Jun 05 2021 at 13:46)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="sd">/// Counts the number of instances of `byte` in `values`</span>
<span class="k">fn</span> <span class="nf">count</span><span class="p">(</span><span class="n">values</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="kt">u8</span><span class="p">],</span><span class="w"> </span><span class="n">byte</span>: <span class="kt">u8</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">u8</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="fm">assert!</span><span class="p">(</span><span class="n">values</span><span class="p">.</span><span class="n">len</span><span class="p">()</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="kt">u8</span>::<span class="n">MAX</span><span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="n">values</span><span class="p">.</span><span class="n">len</span><span class="p">()</span><span class="w"> </span><span class="o">%</span><span class="w"> </span><span class="mi">16</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">count</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">u8x16</span>::<span class="n">splat</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="k">for</span><span class="w"> </span><span class="n">v</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">values</span><span class="p">.</span><span class="n">array_chunks</span><span class="p">().</span><span class="n">map</span><span class="p">(</span><span class="n">u8x16</span>::<span class="n">from_array</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">count</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">v</span><span class="p">.</span><span class="n">lanes_eq</span><span class="p">(</span><span class="n">u8x16</span>::<span class="n">splat</span><span class="p">(</span><span class="n">byte</span><span class="p">)).</span><span class="n">select</span><span class="p">(</span><span class="n">u8x16</span>::<span class="n">splat</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span><span class="w"> </span><span class="n">u8x16</span>::<span class="n">splat</span><span class="p">(</span><span class="mi">0</span><span class="p">));</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="n">count</span><span class="p">.</span><span class="n">horizontal_sum</span><span class="p">()</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="241637457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241637457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241637457">(Jun 05 2021 at 13:46)</a>:</h4>
<p><span class="user-mention" data-user-id="246783">@Miguel Raz Guzmán Macedo</span> something like this</p>



<a name="241637585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241637585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241637585">(Jun 05 2021 at 13:49)</a>:</h4>
<p>Oh neat</p>



<a name="241637604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241637604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241637604">(Jun 05 2021 at 13:49)</a>:</h4>
<p>Where's the masking though? In the select?</p>



<a name="241637664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241637664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241637664">(Jun 05 2021 at 13:50)</a>:</h4>
<p>Yes, <code>lanes_eq</code> returns a mask, and the select does something that looks kind of like branching</p>



<a name="241637884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241637884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241637884">(Jun 05 2021 at 13:55)</a>:</h4>
<p>Ah, I missed the lanes_eq. Thanks!</p>



<a name="241637928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241637928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241637928">(Jun 05 2021 at 13:56)</a>:</h4>
<p>No problem</p>



<a name="241637942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241637942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241637942">(Jun 05 2021 at 13:57)</a>:</h4>
<p>So this a SIMDified find and count loop, right?</p>



<a name="241637945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241637945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241637945">(Jun 05 2021 at 13:57)</a>:</h4>
<p>Yep</p>



<a name="241637949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241637949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241637949">(Jun 05 2021 at 13:57)</a>:</h4>
<p>Coooooool <span aria-label="octopus" class="emoji emoji-1f419" role="img" title="octopus">:octopus:</span></p>



<a name="241637952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241637952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241637952">(Jun 05 2021 at 13:57)</a>:</h4>
<p>The notable part is that the algorithm doesn't branch (other than in the for loop)</p>



<a name="241638005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241638005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241638005">(Jun 05 2021 at 13:58)</a>:</h4>
<p>In normal code branching is efficient but in simd it can be orders of magnitude slower than the rest of your operations</p>



<a name="241645237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241645237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241645237">(Jun 05 2021 at 16:48)</a>:</h4>
<p>I think it would be neat if the <code>examples/*</code> could benchmark the scalar vs different SIMD implementations, so that people can see how to iterate SIMD designs for performance.</p>



<a name="241645249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241645249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241645249">(Jun 05 2021 at 16:48)</a>:</h4>
<p>What's the lowest effort way to setup benchmarking for <code>examples/*</code>?</p>



<a name="241647535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241647535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241647535">(Jun 05 2021 at 17:41)</a>:</h4>
<p>I don't know! :D</p>



<a name="241647823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241647823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241647823">(Jun 05 2021 at 17:49)</a>:</h4>
<div class="message_inline_image"><a href="https://welovecatsandkittens.com/wp-content/uploads/2013/09/sad-kitty.jpg"><img src="https://uploads.zulipusercontent.net/580206040ccec10eccdf434ff4172694a2e8745d/68747470733a2f2f77656c6f766563617473616e646b697474656e732e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031332f30392f7361642d6b697474792e6a7067"></a></div>



<a name="241650342"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241650342" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241650342">(Jun 05 2021 at 18:35)</a>:</h4>
<p>To clarify the bit on region based memory management:<br>
Reference counting basically works on "item A has a number N somewhere. If N hits 0, A is deallocated."<br>
Region based memory management does not require this.<br>
Instead, we define all the scopes in the program, and then at the end of a scope, we run the destructors of all the values that end with that scope. So if something is deallocated, we know exactly where: upon the collapse of a certain scope. So it only has to allocate and deallocate once, ever, and it does so deterministically rather than based on a counter, which could be incremented and decremented a million times without deallocating it. A lot of overhead. Or, in certain cases, reference counting can yield cycles where something is never deallocated.</p>



<a name="241650398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241650398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241650398">(Jun 05 2021 at 18:36)</a>:</h4>
<p>Neat.</p>



<a name="241650403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241650403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241650403">(Jun 05 2021 at 18:36)</a>:</h4>
<p>I hope to learn enough Rust to get MMtk bindings to Julia some day.</p>



<a name="241651488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241651488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241651488">(Jun 05 2021 at 19:00)</a>:</h4>
<p>note that "a scope" in many cases may be directly analogous to "a stack frame", so you can basically think of it as a special case of a local, where it runs code on <code>ret</code>.</p>



<a name="241657819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241657819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241657819">(Jun 05 2021 at 21:53)</a>:</h4>
<p>the game dev folks are absolutely bonkers for a frame allocator</p>



<a name="241658028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241658028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241658028">(Jun 05 2021 at 21:58)</a>:</h4>
<p>What's that?</p>



<a name="241659893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241659893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241659893">(Jun 05 2021 at 22:53)</a>:</h4>
<p>hehe</p>



<a name="241667392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241667392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241667392">(Jun 06 2021 at 02:33)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="281757">@Jubilee</span> , a kind redditor pointed this out from my blog post:<br>
<a href="https://github.com/gnzlbg/cargo-asm">https://github.com/gnzlbg/cargo-asm</a></p>



<a name="241667399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241667399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241667399">(Jun 06 2021 at 02:33)</a>:</h4>
<p>Now to figure out how to get it to emit asm for the <code>examples/*</code> stuff...</p>



<a name="241667956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241667956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241667956">(Jun 06 2021 at 02:50)</a>:</h4>
<p>oh neat.</p>



<a name="241667960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241667960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241667960">(Jun 06 2021 at 02:51)</a>:</h4>
<p>right I think I even used this once, and then had every one of my hard drives crash.</p>



<a name="241668101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241668101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241668101">(Jun 06 2021 at 02:55)</a>:</h4>
<p>I'm fighting the <span aria-label="triangular flag" class="emoji emoji-1f6a9" role="img" title="triangular flag">:triangular_flag:</span> to get it to emit the asm for <code>dot_product</code></p>



<a name="241668725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241668725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241668725">(Jun 06 2021 at 03:08)</a>:</h4>
<p>Any help anyone?</p>



<a name="241668847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241668847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241668847">(Jun 06 2021 at 03:11)</a>:</h4>
<p>hm?</p>



<a name="241668911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241668911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241668911">(Jun 06 2021 at 03:12)</a>:</h4>
<div class="codehilite" data-code-language="Bash"><pre><span></span><code><span class="o">]</span>&gt; cargo asm --example dot_product
error: Found argument <span class="s1">'--example'</span> which wasn<span class="s1">'t expected, or isn'</span>t valid <span class="k">in</span> this context

USAGE:
    cargo asm <span class="o">[</span>FLAGS<span class="o">]</span> <span class="o">[</span>OPTIONS<span class="o">]</span> <span class="o">[</span>--<span class="o">]</span> <span class="o">[</span>path<span class="o">]</span>

For more information try --help
</code></pre></div>



<a name="241670838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241670838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241670838">(Jun 06 2021 at 04:03)</a>:</h4>
<p>it's entirely possible that cargo asm doesn't support examples</p>



<a name="241670851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241670851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241670851">(Jun 06 2021 at 04:03)</a>:</h4>
<p>though i'd be a little curious about why</p>



<a name="241670925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241670925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241670925">(Jun 06 2021 at 04:05)</a>:</h4>
<p>I am once again</p>



<a name="241670931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241670931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241670931">(Jun 06 2021 at 04:05)</a>:</h4>
<p>pouting my face</p>



<a name="241671351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241671351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241671351">(Jun 06 2021 at 04:13)</a>:</h4>
<p><span class="user-mention silent" data-user-id="246783">Miguel Raz Guzmán Macedo</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/241668725">said</a>:</p>
<blockquote>
<p>Any help anyone?</p>
</blockquote>
<p>No idea about <code>cargo asm</code>, but I just use</p>
<div class="codehilite"><pre><span></span><code>rustc +stage1 whatever.rs -O --emit=mir --emit=llvm-ir --emit=asm -C &quot;llvm-args=-x86-asm-syntax=intel&quot;
</code></pre></div>



<a name="241671466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241671466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241671466">(Jun 06 2021 at 04:15)</a>:</h4>
<p>Ooooooh!</p>



<a name="241671470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241671470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241671470">(Jun 06 2021 at 04:15)</a>:</h4>
<p>what's the <code>stage1</code> option for?</p>



<a name="241671472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241671472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241671472">(Jun 06 2021 at 04:15)</a>:</h4>
<p>Oh, that's because I'm using <code>rustup toolchain link</code> to run the one I built myself.</p>



<a name="241671516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241671516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241671516">(Jun 06 2021 at 04:16)</a>:</h4>
<p>It's the same as the normal <code>+stable</code> or <code>+beta</code> or <code>+nightly</code> that rustup's wrappers provide for all these things.</p>



<a name="241671517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241671517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241671517">(Jun 06 2021 at 04:16)</a>:</h4>
<p>...</p>



<a name="241671520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241671520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241671520">(Jun 06 2021 at 04:16)</a>:</h4>
<p>I'm sorry, I just have more questions now. <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="241673361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241673361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241673361">(Jun 06 2021 at 05:06)</a>:</h4>
<p><span class="user-mention silent" data-user-id="246783">Miguel Raz Guzmán Macedo</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/241671520">said</a>:</p>
<blockquote>
<p>I'm sorry, I just have more questions now. <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>
</blockquote>
<p>Well, then ask. <span aria-label="eyes" class="emoji emoji-1f440" role="img" title="eyes">:eyes:</span></p>



<a name="241730977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241730977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241730977">(Jun 07 2021 at 05:30)</a>:</h4>
<p>Uuuh, being really silly - if I do <code>cargo new foo</code>, how do I add <code>stdsimd</code> to the project? <code>cargo add stdsimd</code> does not work..</p>



<a name="241733731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241733731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241733731">(Jun 07 2021 at 06:23)</a>:</h4>
<p>probably like this: <a href="https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-dependencies-from-git-repositories">https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-dependencies-from-git-repositories</a></p>



<a name="241733817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241733817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241733817">(Jun 07 2021 at 06:24)</a>:</h4>
<p>or if your new thing is going to live in the stdsimd repo itself, scroll down a bit to path dependencies and you can use a relative path</p>



<a name="241803703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241803703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241803703">(Jun 07 2021 at 16:32)</a>:</h4>
<p>Hmmm - I think I should PR a <code>hello world</code> config to the stdsimd guide</p>



<a name="241803742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241803742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241803742">(Jun 07 2021 at 16:32)</a>:</h4>
<p>I have this </p>
<div class="codehilite"><pre><span></span><code>[package]
name = &quot;stagedfilter&quot;
version = &quot;0.1.0&quot;
edition = &quot;2018&quot;

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
core_simd = { git = &quot;https://github.com/rust-lang/stdsimd&quot; }
</code></pre></div>



<a name="241803756"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241803756" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241803756">(Jun 07 2021 at 16:32)</a>:</h4>
<p>And I get complaints about</p>



<a name="241803783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241803783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241803783">(Jun 07 2021 at 16:33)</a>:</h4>
<div class="codehilite"><pre><span></span><code>    = note: see issue #78835 &lt;https://github.com/rust-lang/rust/issues/78835&gt; for more information
    = help: add `#![feature(extended_key_value_attributes)]` to the crate attributes to enable
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
</code></pre></div>



<a name="241803843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241803843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241803843">(Jun 07 2021 at 16:33)</a>:</h4>
<p><span class="user-mention" data-user-id="246783">@Miguel Raz Guzmán Macedo</span>  <code>rustup update</code></p>



<a name="241803844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241803844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241803844">(Jun 07 2021 at 16:33)</a>:</h4>
<p>^^;</p>



<a name="241803859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241803859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241803859">(Jun 07 2021 at 16:33)</a>:</h4>
<p>Try updating your compiler, that feature should be stable</p>



<a name="241803867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241803867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241803867">(Jun 07 2021 at 16:33)</a>:</h4>
<p>Yeah that</p>



<a name="241804121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241804121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241804121">(Jun 07 2021 at 16:35)</a>:</h4>
<p>I agree, you should PR a hello world config, honestly go ahead and put it in the README.md<br>
and you should also add a note that users should probably run <code>rustup update</code> if the library doesn't compile.</p>



<a name="241805454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241805454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241805454">(Jun 07 2021 at 16:44)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/241803843">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="246783">Miguel Raz Guzmán Macedo</span>  <code>rustup update</code></p>
</blockquote>
<p>Well that's embarrassing <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> . Alright, everything works now, thanks! mocking up the PR to the guide now.</p>



<a name="241807584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241807584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241807584">(Jun 07 2021 at 16:59)</a>:</h4>
<p>pew pew <span class="user-mention" data-user-id="281757">@Jubilee</span> <a href="https://github.com/rust-lang/stdsimd/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc">https://github.com/rust-lang/stdsimd/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc</a></p>



<a name="241868905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241868905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241868905">(Jun 08 2021 at 04:13)</a>:</h4>
<p>FINALLY</p>



<a name="241868948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241868948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241868948">(Jun 08 2021 at 04:14)</a>:</h4>
<p>using the <code>hello world</code> from the README and <code>cargo asm</code> I finally got this</p>



<a name="241868951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241868951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241868951">(Jun 08 2021 at 04:14)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w"> </span><span class="n">mrg</span><span class="o">@</span><span class="n">JuliaLap</span><span class="w"> </span><span class="o">~/</span><span class="n">p</span><span class="o">/</span><span class="n">r</span><span class="o">/</span><span class="n">s</span><span class="o">/</span><span class="n">src</span><span class="w"> </span><span class="p">(</span><span class="n">master</span><span class="p">)</span><span class="o">&gt;</span><span class="w"> </span><span class="n">cargo</span><span class="w"> </span><span class="n">asm</span><span class="w"> </span><span class="n">stagedfilter</span>::<span class="n">main</span><span class="w"> </span><span class="o">--</span><span class="n">no</span><span class="o">-</span><span class="n">default</span><span class="o">-</span><span class="n">features</span><span class="w"> </span><span class="o">--</span><span class="n">rust</span><span class="w"></span>
<span class="n">file</span><span class="w"> </span><span class="o">/</span><span class="n">rustc</span><span class="o">/</span><span class="n">b663c0f4f6ff84a8c9df0f708e1f8d628330d973</span><span class="o">/</span><span class="n">library</span><span class="o">/</span><span class="n">core</span><span class="o">/</span><span class="n">src</span><span class="o">/</span><span class="n">fmt</span><span class="o">/</span><span class="k">mod</span><span class="p">.</span><span class="n">rs</span><span class="w"> </span><span class="n">does</span><span class="w"> </span><span class="n">not</span><span class="w"> </span><span class="n">exist</span><span class="o">!</span><span class="w"></span>
<span class="w"> </span><span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="n">sub</span><span class="w">     </span><span class="n">rsp</span><span class="p">,</span><span class="w"> </span><span class="mi">88</span><span class="w"></span>
<span class="w">     </span><span class="n">impl_float_ops</span><span class="o">!</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">(</span><span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">mrg</span><span class="o">/</span><span class="p">.</span><span class="n">cargo</span><span class="o">/</span><span class="n">git</span><span class="o">/</span><span class="n">checkouts</span><span class="o">/</span><span class="n">stdsimd</span><span class="o">-</span><span class="mf">26e23068</span><span class="n">d55c82a1</span><span class="o">/</span><span class="mi">4311</span><span class="n">c06</span><span class="o">/</span><span class="n">crates</span><span class="o">/</span><span class="n">core_simd</span><span class="o">/</span><span class="n">src</span><span class="o">/</span><span class="n">ops</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">667</span><span class="p">)</span><span class="w"></span>
<span class="w">     </span><span class="n">movaps</span><span class="w">  </span><span class="n">xmm0</span><span class="p">,</span><span class="w"> </span><span class="n">xmmword</span><span class="p">,</span><span class="w"> </span><span class="n">ptr</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">rip</span><span class="p">,</span><span class="w"> </span><span class="o">+</span><span class="p">,</span><span class="w"> </span><span class="p">.</span><span class="n">LCPI7_0</span><span class="p">]</span><span class="w"></span>
<span class="w">     </span><span class="n">movaps</span><span class="w">  </span><span class="n">xmmword</span><span class="p">,</span><span class="w"> </span><span class="n">ptr</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">rsp</span><span class="p">,</span><span class="w"> </span><span class="o">+</span><span class="p">,</span><span class="w"> </span><span class="mi">16</span><span class="p">],</span><span class="w"> </span><span class="n">xmm0</span><span class="w"></span>
<span class="w">     </span><span class="n">lea</span><span class="w">     </span><span class="n">rax</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">rsp</span><span class="p">,</span><span class="w"> </span><span class="o">+</span><span class="p">,</span><span class="w"> </span><span class="mi">16</span><span class="p">]</span><span class="w"></span>
<span class="w"> </span><span class="fm">println!</span><span class="p">(</span><span class="s">"{:?}"</span><span class="p">,</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">b</span><span class="p">)</span><span class="w"></span>
<span class="w"> </span><span class="n">mov</span><span class="w">     </span><span class="n">qword</span><span class="p">,</span><span class="w"> </span><span class="n">ptr</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">rsp</span><span class="p">],</span><span class="w"> </span><span class="n">rax</span><span class="w"></span>
<span class="w"> </span><span class="n">lea</span><span class="w">     </span><span class="n">rax</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">rip</span><span class="p">,</span><span class="w"> </span><span class="o">+</span><span class="p">,</span><span class="w"> </span><span class="n">_ZN9core_simd3fmt89_</span><span class="cp">$LT$impl$u20$core</span><span class="o">..</span><span class="n">fmt</span><span class="o">..</span><span class="n">Debug</span><span class="cp">$u20$for$u20$core_simd</span><span class="o">..</span><span class="n">vector</span><span class="o">..</span><span class="n">float</span><span class="o">..</span><span class="n">SimdF32</span><span class="cp">$LT$_$GT$$GT$</span><span class="mi">3</span><span class="n">fmt17h8911ca4f82dd33a1E</span><span class="p">]</span><span class="w"></span>
<span class="w"> </span><span class="n">mov</span><span class="w">     </span><span class="n">qword</span><span class="p">,</span><span class="w"> </span><span class="n">ptr</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">rsp</span><span class="p">,</span><span class="w"> </span><span class="o">+</span><span class="p">,</span><span class="w"> </span><span class="mi">8</span><span class="p">],</span><span class="w"> </span><span class="n">rax</span><span class="w"></span>
<span class="w">     </span><span class="n">lea</span><span class="w">     </span><span class="n">rax</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">rip</span><span class="p">,</span><span class="w"> </span><span class="o">+</span><span class="p">,</span><span class="w"> </span><span class="p">.</span><span class="n">L__unnamed_3</span><span class="p">]</span><span class="w"></span>
<span class="w">     </span><span class="n">mov</span><span class="w">     </span><span class="n">qword</span><span class="p">,</span><span class="w"> </span><span class="n">ptr</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">rsp</span><span class="p">,</span><span class="w"> </span><span class="o">+</span><span class="p">,</span><span class="w"> </span><span class="mi">40</span><span class="p">],</span><span class="w"> </span><span class="n">rax</span><span class="w"></span>
<span class="w">     </span><span class="n">mov</span><span class="w">     </span><span class="n">qword</span><span class="p">,</span><span class="w"> </span><span class="n">ptr</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">rsp</span><span class="p">,</span><span class="w"> </span><span class="o">+</span><span class="p">,</span><span class="w"> </span><span class="mi">48</span><span class="p">],</span><span class="w"> </span><span class="mi">2</span><span class="w"></span>
<span class="w">     </span><span class="n">mov</span><span class="w">     </span><span class="n">qword</span><span class="p">,</span><span class="w"> </span><span class="n">ptr</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">rsp</span><span class="p">,</span><span class="w"> </span><span class="o">+</span><span class="p">,</span><span class="w"> </span><span class="mi">56</span><span class="p">],</span><span class="w"> </span><span class="mi">0</span><span class="w"></span>
<span class="w">     </span><span class="n">mov</span><span class="w">     </span><span class="n">rax</span><span class="p">,</span><span class="w"> </span><span class="n">rsp</span><span class="w"></span>
<span class="w">     </span><span class="n">mov</span><span class="w">     </span><span class="n">qword</span><span class="p">,</span><span class="w"> </span><span class="n">ptr</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">rsp</span><span class="p">,</span><span class="w"> </span><span class="o">+</span><span class="p">,</span><span class="w"> </span><span class="mi">72</span><span class="p">],</span><span class="w"> </span><span class="n">rax</span><span class="w"></span>
<span class="w">     </span><span class="n">mov</span><span class="w">     </span><span class="n">qword</span><span class="p">,</span><span class="w"> </span><span class="n">ptr</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">rsp</span><span class="p">,</span><span class="w"> </span><span class="o">+</span><span class="p">,</span><span class="w"> </span><span class="mi">80</span><span class="p">],</span><span class="w"> </span><span class="mi">1</span><span class="w"></span>
<span class="w">     </span><span class="n">lea</span><span class="w">     </span><span class="n">rdi</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">rsp</span><span class="p">,</span><span class="w"> </span><span class="o">+</span><span class="p">,</span><span class="w"> </span><span class="mi">40</span><span class="p">]</span><span class="w"></span>
<span class="w"> </span><span class="n">call</span><span class="w">    </span><span class="n">qword</span><span class="p">,</span><span class="w"> </span><span class="n">ptr</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">rip</span><span class="p">,</span><span class="w"> </span><span class="o">+</span><span class="p">,</span><span class="w"> </span><span class="n">_ZN3std2io5stdio6_print17hb1367a556f058e80E</span><span class="o">@</span><span class="n">GOTPCREL</span><span class="p">]</span><span class="w"></span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w"> </span><span class="n">add</span><span class="w">     </span><span class="n">rsp</span><span class="p">,</span><span class="w"> </span><span class="mi">88</span><span class="w"></span>
<span class="w"> </span><span class="n">ret</span><span class="w"></span>
</code></pre></div>



<a name="241870666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241870666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241870666">(Jun 08 2021 at 04:54)</a>:</h4>
<p>So now begins the real fun part of optimizing SIMD instructions - though I think we gotta pull out the big guns like VTune or something</p>



<a name="241960475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241960475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241960475">(Jun 08 2021 at 17:57)</a>:</h4>
<p>A friend from Julia pointed this out :D<br>
<a href="https://state.smerity.com/smerity/state/01E8RNH7HRRJT2A63NSX3N6SP1">https://state.smerity.com/smerity/state/01E8RNH7HRRJT2A63NSX3N6SP1</a></p>



<a name="241992802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241992802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241992802">(Jun 08 2021 at 21:54)</a>:</h4>
<p>neat!</p>



<a name="241994170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241994170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241994170">(Jun 08 2021 at 22:08)</a>:</h4>
<p>Hmm, that's missing what I'd consider the "obvious" version of the "I know it's 1024 things": pre-slicing to the known length, which is also safe and does well &lt;<a href="https://rust.godbolt.org/z/hancr5dnT">https://rust.godbolt.org/z/hancr5dnT</a>&gt;</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">dotp</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="kt">f32</span><span class="p">],</span><span class="w"> </span><span class="n">y</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="kt">f32</span><span class="p">],</span><span class="w"> </span><span class="n">z</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="p">[</span><span class="kt">f32</span><span class="p">])</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1024</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="n">y</span><span class="p">,</span><span class="w"> </span><span class="n">z</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="o">&amp;</span><span class="n">x</span><span class="p">[</span><span class="o">..</span><span class="n">n</span><span class="p">],</span><span class="w"> </span><span class="o">&amp;</span><span class="n">y</span><span class="p">[</span><span class="o">..</span><span class="n">n</span><span class="p">],</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">z</span><span class="p">[</span><span class="o">..</span><span class="n">n</span><span class="p">]);</span><span class="w"></span>
<span class="w">    </span><span class="k">for</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="mi">0</span><span class="o">..</span><span class="n">n</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">z</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">mul_add</span><span class="p">(</span><span class="n">y</span><span class="p">[</span><span class="n">i</span><span class="p">],</span><span class="w"> </span><span class="n">z</span><span class="p">[</span><span class="n">i</span><span class="p">]);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="241995246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241995246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241995246">(Jun 08 2021 at 22:19)</a>:</h4>
<p>Ooooh can Rust exploit those assertions for unrolling the loop?</p>



<a name="241995260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241995260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241995260">(Jun 08 2021 at 22:19)</a>:</h4>
<p>assertions ~ length of the array here...</p>



<a name="241995916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241995916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241995916">(Jun 08 2021 at 22:27)</a>:</h4>
<p><span class="user-mention silent" data-user-id="246783">Miguel Raz Guzmán Macedo</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/241995246">said</a>:</p>
<blockquote>
<p>Ooooh can Rust exploit those assertions for unrolling the loop?</p>
</blockquote>
<p>yes, it will even optimize things slightly differently if you directly call <code>.len()</code> to check the length of something, because Rust and LLVM will notice that as a "checkpoint".</p>



<a name="241996541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241996541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241996541">(Jun 08 2021 at 22:34)</a>:</h4>
<p>Oooh, I would like to know what that is eventually.</p>



<a name="241996560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241996560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241996560">(Jun 08 2021 at 22:34)</a>:</h4>
<p>I'm about 100 pages into my <code>Learn LLVM 12</code> book now (I skipped the parsing, all my friends hate parsing)</p>



<a name="241996910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241996910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241996910">(Jun 08 2021 at 22:39)</a>:</h4>
<p>I said "checkpoint" like... as a made up term, though you do see occasionally like "synchronization point".<br>
What I mean is that the easier it is for it to follow a variable back to its meaning, the easier it is to optimize around, because it follows the def-use-def more readily.</p>



<a name="241996940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241996940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241996940">(Jun 08 2021 at 22:39)</a>:</h4>
<p>Oh, so that's a good note to make to the diary about Rust code then. Thanks!</p>



<a name="241997052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241997052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241997052">(Jun 08 2021 at 22:41)</a>:</h4>
<p><a href="https://en.wikipedia.org/wiki/Use-define_chain">https://en.wikipedia.org/wiki/Use-define_chain</a></p>



<a name="241997865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241997865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241997865">(Jun 08 2021 at 22:52)</a>:</h4>
<p>I once found this out by fiddling a bunch with something where I had "outside knowledge" about how big a slice <strong>could</strong> be... but if I explicitly called <code>.len()</code> and predicated on that, it still optimized much better than if I only used the "outside knowledge".</p>



<a name="241997921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241997921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241997921">(Jun 08 2021 at 22:53)</a>:</h4>
<p>And that, I imagine, is probably partially because it then hit a bunch of post-hoc predications on <code>len</code> <strong>anyways</strong>, because I did something that could hypothetically panic.</p>



<a name="241998061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998061">(Jun 08 2021 at 22:54)</a>:</h4>
<p>Is there an <code>assume</code> function in rust? The nearest thing I can think of is <code>if !cond { std::hint::unreachable_unchecked() }</code></p>



<a name="241998211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998211">(Jun 08 2021 at 22:56)</a>:</h4>
<p><code>assert!</code> does what you'd want safely</p>



<a name="241998224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998224">(Jun 08 2021 at 22:56)</a>:</h4>
<p>But yeah, it would just be a branch</p>



<a name="241998227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998227">(Jun 08 2021 at 22:56)</a>:</h4>
<p>i've (long ago) seen occasionally that assert is insufficiently aggressive</p>



<a name="241998235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998235">(Jun 08 2021 at 22:56)</a>:</h4>
<p>that still has runtime overhead though</p>



<a name="241998251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998251">(Jun 08 2021 at 22:57)</a>:</h4>
<p>it's just front loading it, which might be fine if it comes before a loop like in the example</p>



<a name="241998271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998271">(Jun 08 2021 at 22:57)</a>:</h4>
<p>In simd code I have often found that using asserts is decently faster than without the assert</p>



<a name="241998325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998325">(Jun 08 2021 at 22:58)</a>:</h4>
<p>but we're not comparing assert / nothing, we're comparing assert / assume</p>



<a name="241998333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998333">(Jun 08 2021 at 22:58)</a>:</h4>
<p>You could make the branch unreachable and it would probably be slightly faster</p>



<a name="241998378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998378">(Jun 08 2021 at 22:59)</a>:</h4>
<p>But remember that if your assertion is over a length that you later iterate over (which is common) the assert is no more costly than the overhead of one loop iteration</p>



<a name="241998481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998481">(Jun 08 2021 at 23:00)</a>:</h4>
<p>I guess that depends on how well the branch is predicted</p>



<a name="241998488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998488">(Jun 08 2021 at 23:00)</a>:</h4>
<p>presumably an assert is easy to predict</p>



<a name="241998505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998505">(Jun 08 2021 at 23:00)</a>:</h4>
<p>assume is pretty insanely unsafe, so.</p>



<a name="241998520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998520">(Jun 08 2021 at 23:01)</a>:</h4>
<p>If your assertion is correct it would be predicted correctly every time</p>



<a name="241998566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998566">(Jun 08 2021 at 23:01)</a>:</h4>
<p>And if it's incorrect it would let you know like <span class="user-mention" data-user-id="281757">@Jubilee</span> noted <span aria-label="grinning" class="emoji emoji-1f600" role="img" title="grinning">:grinning:</span></p>



<a name="241998651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998651">(Jun 08 2021 at 23:02)</a>:</h4>
<p>also fwiw yes, there is a weird thing where Rust can generate branch predicting code with no significant loss of actual speed on processors with even vaguely modern branch prediction.</p>



<a name="241998674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998674">(Jun 08 2021 at 23:02)</a>:</h4>
<p>even though there is More To Love, er, execute.</p>



<a name="241998766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998766">(Jun 08 2021 at 23:03)</a>:</h4>
<p>I am maybe different from other rust users on this point, but in an example like <span class="user-mention silent" data-user-id="125270">scottmcm</span>'s where I have a contract with the caller on the size of the slices, I would prefer to either get that in the type or use an assume over an assert</p>



<a name="241998878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998878">(Jun 08 2021 at 23:04)</a>:</h4>
<p>like, I program as if rust was dependently typed and make up the difference with <code>unsafe</code></p>



<a name="241998885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241998885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241998885">(Jun 08 2021 at 23:04)</a>:</h4>
<p>wild.</p>



<a name="241999056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241999056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241999056">(Jun 08 2021 at 23:07)</a>:</h4>
<p>If your goal is performance I think it's very likely there is no notable difference between an assert and an assume.  Usually the cases that comes up in (like assertions inside loops, resulting in many many asserts) are better solved with a custom iterator (internal, contained unsafety) rather than an assume in the loop (external, uncontained unsafety)</p>



<a name="241999153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241999153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241999153">(Jun 08 2021 at 23:08)</a>:</h4>
<p><code>array_chunks</code> is a good example of that</p>



<a name="241999596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/241999596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#241999596">(Jun 08 2021 at 23:14)</a>:</h4>
<p>I often find myself referring to this example. C can be more optimal in instruction count and therefore size than Rust code, but modern superscalar processors can retire the instructions generated by Rust shockingly swiftly, making the overhead vs. C much more thin in actual performance. <a href="https://github.com/ixy-languages/ixy-languages/blob/master/Rust-vs-C-performance.md">https://github.com/ixy-languages/ixy-languages/blob/master/Rust-vs-C-performance.md</a></p>



<a name="242001879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/242001879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#242001879">(Jun 08 2021 at 23:48)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/241998566">said</a>:</p>
<blockquote>
<p>And if it's incorrect it would let you know like <span class="user-mention silent" data-user-id="281757">Jubilee</span> noted <span aria-label="grinning" class="emoji emoji-1f600" role="img" title="grinning">:grinning:</span></p>
</blockquote>
<p>actually if your assumption isn't correct it won't do anything specific at all ;3</p>



<a name="242002766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/242002766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#242002766">(Jun 09 2021 at 00:01)</a>:</h4>
<p><span class="user-mention silent" data-user-id="246783">Miguel Raz Guzmán Macedo</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/241995246">said</a>:</p>
<blockquote>
<p>Ooooh can Rust exploit those assertions for unrolling the loop?</p>
</blockquote>
<p>Yes, absolutely.  Re-slicing to a common length typically helps LLVM realize that multiple slices have the same length, which helps both remove the bounds checks as well as to canonicalize the loop.</p>
<p>Here's a simple example of how assertions or slicing helps remove bound checks: <a href="https://rust.godbolt.org/z/Pqrq5cv3h">https://rust.godbolt.org/z/Pqrq5cv3h</a></p>



<a name="242002842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/242002842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#242002842">(Jun 09 2021 at 00:02)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/241998061">said</a>:</p>
<blockquote>
<p>Is there an <code>assume</code> function in rust? The nearest thing I can think of is <code>if !cond { std::hint::unreachable_unchecked() }</code></p>
</blockquote>
<p>If you want the "UB if false" version, it's &lt;<a href="https://doc.rust-lang.org/nightly/std/intrinsics/fn.assume.html">https://doc.rust-lang.org/nightly/std/intrinsics/fn.assume.html</a>&gt;, which is a direct wrapper on &lt;<a href="https://llvm.org/docs/LangRef.html#llvm-assume-intrinsic">https://llvm.org/docs/LangRef.html#llvm-assume-intrinsic</a>&gt;.</p>
<p>But note that adding <code>assume</code>s can paradoxically also inhibit other optimizations, because it leads to more IR and more "uses" of variables.</p>



<a name="242003002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/242003002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#242003002">(Jun 09 2021 at 00:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/241998766">said</a>:</p>
<blockquote>
<p>I am maybe different from other rust users on this point, but in an example like <span class="user-mention silent" data-user-id="125270">scottmcm</span>'s where I have a contract with the caller on the size of the slices, I would prefer to either get that in the type or use an assume over an assert</p>
</blockquote>
<p>Absolutely it would be better to write that example by taking <code>&amp;[T; 1024]</code> instead of <code>&amp;[T]</code>, but I wanted to closer parallel the C versions.</p>
<p>(By taking the reference to the array it moves the proof obligation to the caller, where for example they can satisfy it by using <code>as_chunks</code> or <code>.try_into()</code> or whatever.)</p>



<a name="242003234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/242003234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#242003234">(Jun 09 2021 at 00:08)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/241999596">said</a>:</p>
<blockquote>
<p>I often find myself referring to this example. [...] <a href="https://github.com/ixy-languages/ixy-languages/blob/master/Rust-vs-C-performance.md">https://github.com/ixy-languages/ixy-languages/blob/master/Rust-vs-C-performance.md</a></p>
</blockquote>
<p>Ooh, great post!  Thanks for sharing.  Branch predictors OP <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="242003580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/242003580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#242003580">(Jun 09 2021 at 00:13)</a>:</h4>
<p>Worth noting that branches can optimize to <code>assume</code> as you'd expect: <a href="https://rust.godbolt.org/z/jGP3PGsbT">https://rust.godbolt.org/z/jGP3PGsbT</a></p>



<a name="242003967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/242003967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#242003967">(Jun 09 2021 at 00:19)</a>:</h4>
<p>Yeah, there's actually a somewhat paradoxical technique that modern optimizers can exploit, because they tend to hinge around the concept of finding reducible expressions, whether those are common subexpressions or whatever, of restructuring the code to be <strong>less</strong> optimal, even injecting additional ops, but is fully <strong>reducible</strong> in the following optimization passes, allowing you to add 1 or 2 lines of code to delete 5 or 10.</p>
<p>I can't find the paper on this I remember encountering though.</p>



<a name="242004222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/242004222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#242004222">(Jun 09 2021 at 00:23)</a>:</h4>
<p>I think a good way to look at it is if there's an obvious (and valid) optimization that you see as the programmer, the compiler does it.  I think that's more or less why the reducible expressions work.  The optimizer is clever but it isn't magic and usually "indicate something to other programmers via assert" and "indicate something to the optimizer via assert" are the same thing</p>



<a name="242004307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/242004307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#242004307">(Jun 09 2021 at 00:24)</a>:</h4>
<p>Also true for other types of simple branches</p>



<a name="242004384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/242004384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#242004384">(Jun 09 2021 at 00:25)</a>:</h4>
<p>Any bit of rust code generates so much LLVM because of the type system etc just using rust at all is already making the assumption that the optimizer is exceptionally good</p>



<a name="242004534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/242004534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#242004534">(Jun 09 2021 at 00:27)</a>:</h4>
<p>AHA here was one of them: "symbiotic expressions". <a href="https://www.sac-home.org/_media/publications:pdf:2009_1.pdf">https://www.sac-home.org/_media/publications:pdf:2009_1.pdf</a></p>



<a name="242004692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/242004692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#242004692">(Jun 09 2021 at 00:30)</a>:</h4>
<p>"just jam more code DIRECTLY into the program and your optimizer will optimize more, this turns out to be particularly applicable to anything involving arrays, but it generalizes well."</p>



<a name="242004732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/242004732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#242004732">(Jun 09 2021 at 00:31)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/241998878">said</a>:</p>
<blockquote>
<p>like, I program as if rust was dependently typed and make up the difference with <code>unsafe</code></p>
</blockquote>
<p>Here's a trick you can use for that while still being safe: &lt;<a href="https://rust.godbolt.org/z/3bxrGqjdh">https://rust.godbolt.org/z/3bxrGqjdh</a>&gt;</p>
<p>By inlining the checks into the caller, without necessarily inlining the whole body, you can give the optimizer context that makes it easier for it to remove those checks.</p>



<a name="242004803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/242004803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#242004803">(Jun 09 2021 at 00:32)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples/near/242004692">said</a>:</p>
<blockquote>
<p>"just jam more code DIRECTLY into the program and your optimizer will optimize more"</p>
</blockquote>
<p>In a way this is the idea behind VSDG too, as I understand it -- just provide more and more ways of doing the same thing, and let the optimizer pick the best one later.</p>



<a name="242010095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/242010095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#242010095">(Jun 09 2021 at 02:00)</a>:</h4>
<p>interesting</p>



<a name="243447424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/243447424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#243447424">(Jun 21 2021 at 21:44)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> I'm guessing implementing the <code>std::Iterator::Sum</code> trait is not in scope for porting the <code>dot_product</code> example, right?</p>



<a name="243447444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/243447444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#243447444">(Jun 21 2021 at 21:44)</a>:</h4>
<p>Nope, that's in my PR though</p>



<a name="243447450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/243447450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#243447450">(Jun 21 2021 at 21:44)</a>:</h4>
<p>That is one of the things that should be in.. .yeah, <a href="https://github.com/rust-lang/rust/issues/136">#136</a>!</p>



<a name="243447505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/243447505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#243447505">(Jun 21 2021 at 21:45)</a>:</h4>
<p>Oh neat neat.</p>



<a name="243447508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/243447508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#243447508">(Jun 21 2021 at 21:45)</a>:</h4>
<p>Though I just realized I think I am questioning how it's implemented, since it's not doing precisely an in-order sum (not even sure if that's what we'd expect)</p>



<a name="243447522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Porting%20benchamark%20examples/near/243447522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Porting.20benchamark.20examples.html#243447522">(Jun 21 2021 at 21:45)</a>:</h4>
<p>It could be documented</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>